Authorize app call to API on behalf of user via OAuth2

Does anyone have experience using Google Apps Script to enable an AppSheet app user to authorize API calls to a 3rd-party API service that uses OAuth2? I'm trying to do that with the Twitter API, but can't get one particular flow to work: authorizing the app (or, more precisely, the script) to call the API on behalf of a user besides me. I've got a setup partially working, including using automations with Call a script tasks that return values such as the authorization URL where the user can authorize the app to access their Twitter account. However, for users besides me they always end up with an error from Apps Script after authorizing access:

  • The state token is invalid or has expired. Please try again.

If someone has experience and availability, I'd appreciate the opportunity to talk through the details and figure this out.

1 3 314
3 REPLIES 3

Hello dbaum!. Were you able to resolve this issue? I want to connect to Zoho API

No. Also tried again recently with Spotify, but was unsuccessful.

One thing I'd just try (shooting in the dark) is to isolate the authentication function in a separate script, explicitly give users read access to this script file, let them access it and in the process authorize the script using their own accounts. 

Top Labels in this Space