This describes how to authenticate with Podio using Goa, 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.


Normal pattern

The normal pattern for a webapp type OAuth2 flow is to check if consent is needed with goa.needsConsent() , and if so to return goa.getConsent() for processing by your doGet/doPost function. When a token is received either through this consent or by refreshing a token without the need for a dialog, the flow continues transparently in your doGet servicing function.

Alternative onToken call back.

You might be preferable just to call some function when a token is detected. Goa allows the setting of an callback when a token is eventually received like this.
This example uses an anonymous function, called when the token process is completed. It  receives the token , the name of the credentials package and any arguments originally present when the Goa process started.
Equally this could have been a regular named function.

A note on arguments and lexical scoping

Any  arguments handled in this way must be stringifiable objects – remember that could be passed to an entirely different instance of your app so are reinitialized. Similarly, anonymous functions can’t rely on lexical scoping to inherit values for the same reason.
Why not join our forum, follow the blog or follow me on Twitter to ensure you get updates when they are available