apps-script-oauth2 icon indicating copy to clipboard operation
apps-script-oauth2 copied to clipboard

ERROR: Unexpected token t in JSON at position 1

Open leetlezee opened this issue 3 years ago • 1 comments

Normally, my code using this library runs perfectly fine, but maybe once every month or couple of months, I get this issue referencing the Storage.gs and Service.gs files in the Oauth2 library.

Error SyntaxError: Unexpected token t in JSON at position 1 Storage_.getValue @ Storage.gs:89 Service_.getToken @ Service.gs:647 Service_.hasAccess @ Service.gs:424 Service_.getAccessToken @ Service.gs:465

I get this error when the second line of this code is run:

  let service = getService();
  let accessToken = service.getAccessToken();

The only way I've found to get around this error is by resetting the service and authorizing the application again.

leetlezee avatar Jul 06 '21 15:07 leetlezee

It looks like the value being retrieved from storage (cache or properties) is not valid JSON. It's unclear what it does contain though, and how it got that way. Next time this happens, look at the values in the cache and properties to see what's in there.

erickoledadevrel avatar Jul 08 '21 13:07 erickoledadevrel