Search code examples
google-apps-scriptgoogle-cloud-platformpostmanhttp-status-code-403google-apps-script-api

Making a request to the Google Apps Script API through postman


I am attempting to remotely execute a google apps script function using the apps script api through a postman request.

I first get credentials from the Google API Playground

Then they are inputted into postman as OAuth2 credentials, and inputted in the headers like this: enter image description here

Then the appropriate link is requested: enter image description here

Then the body prepared: enter image description here

And then the response after making the request: enter image description here

Postman is returning an error 403, which, according to Google's documentation

indicates that "the Cloud Platform project used to authorize the request is not the same as the one used by the script." An error 403 is an authorization error and can mean many things, but let's assume that the error is what google proclaims it to be.

I have full control over the GCP project utilized by my script, but I'm not aware of where to find the project that was used to authorize the request.

Where might I gain access to this GCP project so I can assign my script to this project, thereby eliminating the 403 error?

Thanks!


Solution

  • To use OAuth Access Tokens from the OAuth Playground with Apps Script, you need to specify the correct Client ID and Client Secret from the same project.

    In the OAuth Playground. Click on the gear icon (top right). Select "Use your own OAuth credentials". Then enter the Client ID and Secret ID created in the same project as Apps Script.