Open quochuy opened 9 years ago
Can you describe in details whats not working?
The first time you auth, it's OK, you get the access token and can access the API. But when the token expires, you should be able to request a token refresh but instead the script failed with an HTTP error (bad request) and it then redo the auth thing where it opens a webview and ask your permission.
The problem was that your refreshToken function is posting the request to the wrong URL. https://accounts.google.com/o/oauth2/auth should be use for first time authentication. For token refresh it should be https://www.googleapis.com/oauth2/v3/token as per: https://developers.google.com/identity/protocols/OAuth2WebServer#refresh
And I've applied this to my copy of the file and it works
Thanks for explanation! I will update the code.
The fix is at line 24 add: refreshUrl: 'https://www.googleapis.com/oauth2/v3/token',
Then at line 259 change: xhr.open("POST", _opt.url);
to: xhr.open("POST", _opt.refreshUrl);