Search code examples
google-apps-scriptoauth-2.0google-oauth

How to set resource when creating OAuth service in Google App Script


In Postman, I have my GET request set up to where I can get the correct access key using grant_type, client_id, client_secret, and resource in my request body.

enter image description here

I'm trying to get this working in Google App Script, however there does not appear to be a setResource function. I've looked through the documentation and could not find an alternative. Is it possible to somehow set the resource to get the proper access key with Google App Script OAuth2? https://github.com/googleworkspace/apps-script-oauth2/blob/master/dist/OAuth2.gs

enter image description here


Solution

  • You can set an additional parameter for constructing the authorization URL by using .setParam().

    .setParam('resource', 'https://storage.azure.com/')