-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathloadplotlycredentials.m
More file actions
27 lines (22 loc) · 1.08 KB
/
loadplotlycredentials.m
File metadata and controls
27 lines (22 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function creds = loadplotlycredentials()
userhome = getuserdir();
plotly_credentials_file = fullfile(userhome, '.plotly', '.credentials');
% check if credentials exist
if ~exist(plotly_credentials_file, 'file')
error('Plotly:CredentialsNotFound', ['It looks like you ' ...
'haven''t set up your plotly account credentials ' ...
'yet.\nTo get started, save your plotly username and ' ...
'API key by calling:\n>>> saveplotlycredentials(' ...
'username, api_key)\n\nFor more help, see ' ...
'https://plot.ly/MATLAB or contact chris@plot.ly.']);
end
fileIDCred = fopen(plotly_credentials_file, 'r');
if (fileIDCred == -1)
error('plotly:loadcredentials', ['There was an error reading ' ...
'your credentials file at ' plotly_credentials_file ...
'. Contact chris@plot.ly for support.']);
end
creds_string_array = fread(fileIDCred, '*char');
creds_string = sprintf('%s',creds_string_array);
creds = jsondecode(creds_string);
end