Closed RonaldJCoote closed 4 years ago
Yes, it is supposed to refresh automatically, and it looks like your have the correct information in the token response. It could be there is some error encountered when refreshing the token. Those errors get swallowed by default, but you can read them using service.getLastError()
. For example:
if (service.hasAccess()) {
// ...
} else {
console.log(service.getLastError());
// ...
}
Closing due to lack of response.
Hi @erickoledadevrel - thanks for your patience. I have confirmed with Zoho Support that it was a problem at their end. They changed the format for the issued tokens and associated parameters, about 18 months ago, to correct this bug. But all previously-issued tokens were not updated - and hence mine were failing since I created mine earlier. (Poor comms on their part, to not alert existing token-owners.....). All now resolved. Thanks again.
Thanks for following up, and glad to hear you found the root cause.
Hi - great sample code, thanks. For the Zoho CRM version, I need to manually reconnect each hour - i.e. the code doesn't appear to be using the refresh tokens automatically.
Zoho says access tokens expire after an hour: https://www.zoho.com/crm/developer/docs/api/refresh.html
The response from the initial auth connection is as follows (gleaned from PropertiesService.getUserProperties().getProperties())):
so a refresh token is being returned correctly.
Is the apps-script-oauth2 code meant to automatically handle refresh tokens?
Thanks,
RC