googleworkspace / apps-script-oauth2

An OAuth2 library for Google Apps Script.
https://developers.google.com/apps-script/
Apache License 2.0
1.56k stars 429 forks source link

refresh_token not stored #279

Closed okigan closed 3 years ago

okigan commented 3 years ago

Looks like refresh_token is not stored, it is used in the refresh method, but does not exist [1].

That being said, I could be wrong -- could you point to place where refresh_token is saved.

[1] https://github.com/googleworkspace/apps-script-oauth2/blob/27c61fcc15af19f9d6505d2a6170ff883f0bd868/src/Service.js#L586

erickoledadevrel commented 3 years ago

refresh_token is a field of the token response, and saved along with all of the other fields here:

https://github.com/googleworkspace/apps-script-oauth2/blob/27c61fcc15af19f9d6505d2a6170ff883f0bd868/src/Service.js#L392-L400

There are some OAuth providers, Google being one, that only return the refresh_token under certain circumstances. For instance, when you request offline access and specify prompt=consent.