Skip to content
Snippets Groups Projects
Commit 48c4b8df authored by Mark Winter's avatar Mark Winter
Browse files

Use try/catch and reauth to handle token expiration

parent 68f442ec
Branches
No related tags found
No related merge requests found
......@@ -33,7 +33,17 @@ function resp = reddit_query(endpoint, tokenObj)
'Timeout',60,...
'HeaderFields',headers);
try
resp = webread(url, opts);
catch me
getAuthToken(tokenObj);
headers = {'Authorization', sprintf('%s %s', tokenObj.TokenType, tokenObj.AccessToken)};
opts = weboptions('UserAgent',tokenObj.UserAgent,...
'Timeout',60,...
'HeaderFields',headers);
resp = webread(url, opts);
end
% Manually reset rate-limits to avoid overloading since matlab doesn't
% support headers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment