When call google script web app url from deployed company's project get java.io.IOException: Server returned HTTP response code: 403 for URL:

Viewed 209

I have created a project in google script with my personal google account. I deployed it as web app with access given to anyone, even anonymous and can execute the app as Me. I used the deployed google script web app url within a project i work on for my company. When i call the url from localhost i get the result from the script. After we deployed the project, which calls the google script web app, we add proxy configuration to the call to google script, as the project runs under vpn, and now i couldn't access the script anymore - i get the following error: java.io.IOException: Server returned HTTP response code: 403 for URL: https://script.googleusercontent.com/macros/echo?user_content_key.

I have searched for a similar issues but honestly couldn't figured out where the problem is and what exactly i have to do. I suppose i have to bind somehow our company project/domain with this google script app am i right? Or the problem is somewhere else?

Any advice will be highly appreciated.

1 Answers

You may need to set up a Cloud Platform Project

The problem

The error 403, PERMISSION_DENIED: The caller does not have permission indicates that the Cloud Platform project used to authorize the request is not the same as the one used by the script.

From this article

In your case, this could mean that since you are calling from an unknown server, that Google does not authorize it.

Possible Solution

  1. Go to https://console.cloud.google.com/ .
  2. Create a new project and take a note of the project number.
  3. Enable the Apps Script API.
  4. Set up an OAuth consent screen.

Applications that access Google APIs from a server (often using languages and frameworks like Node.js, Java, .NET, and Python) must specify authorized redirect URIs. The redirect URIs are the endpoints of your application server to which the OAuth 2.0 server can send responses.

  1. Change the Apps Script default project from the script:

enter image description here

enter image description here

  1. Ensure the scopes are properly configured in your manifest.
  2. Save a new version and redeploy.

You may need to create a new Apps Script, copy your code, link it to the cloud project and then deploy


References

Related