Skip to content

refresh token: service.hasAccess() is true, but UrlFetchApp.fetch() fails after 10 minutes? #22

Closed
@wivaku

Description

@wivaku

I would like to talk to this API:
https://developers.exactonline.com/#OAuth_Tutorial.html

It mentions in step 3:

Use the access token in your API requests. It expires in 10 minutes (600 seconds). Once it has expired you use the refresh token to request a new access token.

Using the OAuth library reference code I can indeed authorize and I can use the access token to make a request. After 10 minutes service.hasAccess() still returns true, but I for the UrlFetchApp.fetch() I get an error 500. After I use the clearService() example of the OAuth library I can let the user authorize again and it works again for 10 minutes.

How can I follow the instructions of Exact's API to use the refresh token to request a new access token?

edit: in the Service.gs code I see refresh support is built in. I see there is a method .setExpirationMinutes(). Will try that one. Is there documentation of the various methods other than the source code?

edit: using .setExpirationMinutes(10).setParam('access_type', 'offline') did not have the wanted result. Also tried 9 minutes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions