forked from plotly/plotly_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadplotlycredentials.m
More file actions
30 lines (23 loc) · 992 Bytes
/
loadplotlycredentials.m
File metadata and controls
30 lines (23 loc) · 992 Bytes
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
28
29
30
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\n'...
'For 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 = loadjson(creds_string);
end