Opting out of automatic token refreshes

This describes how to authenticate with Google Datastore using Goa, and opting out of automatic refreshing, as described in Oauth2 for Apps Script in a few lines of code (which you should read first for background).

The library, cGoa, is available under this project key, or on github. All the tests described for this topic are also available on github.

MZx5DzNPsYjVyZaR67xXJQai_d-phDA33

Refresh token opt out.

In Accessing as the user running the script I described how to generate separate token packages for each user running the script, mainly for webapps  published like this.


Once authorized this pattern will store an individual refresh token for each user in their UserProperties so that in future, access can be made without the need to re-authorize through the OAuth2 dialog. Users can opt out of this through this check box in the consent screen.
If unchecked, then no refresh token will be retrieved, so the user will have to re-authorize when the current token expires.

For more like this, see OAuth2 for Apps Script in a few lines of code Why not join our forumfollow the blog or follow me on twitter to ensure you get updates when they are available. 

You want to learn Google Apps Script?

Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, All formats are available from O'ReillyAmazon and all good bookshops. You can also read a preview on O'Reilly

If you prefer Video style learning I also have two courses available. also published by O'Reilly.
Google Apps Script for Developers and Google Apps Script for Beginners.




Comments