我已经使用我的个人谷歌帐户在谷歌脚本中创建了一个项目。我将其部署为网络应用程序,并授予任何人(甚至匿名)访问权限,并且可以我身份执行该应用程序。我在我为公司工作的项目中使用了部署的谷歌脚本网络应用程序网址。当我从本地主机调用 url 时,我从脚本中得到结果。在我们部署了调用 google script web 应用程序的项目后,我们将代理配置添加到对 google script 的调用中,因为该项目在 vpn 下运行,现在我无法再访问该脚本 - 我收到以下错误:< strong>java.io.IOException:服务器返回 HTTP 响应代码:403 对于 URL:https://script.googleusercontent.com/macros/echo?user_content_key 。
我已经搜索过类似的问题,但老实说无法弄清楚问题出在哪里以及我到底需要做什么。我想我必须以某种方式将我们公司的项目/域与这个谷歌脚本应用程序绑定(bind),对吗?或者问题出在其他地方?
任何建议都将受到高度赞赏。
最佳答案
您可能需要设置 Cloud Platform Project
问题
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.
从此article
就您而言,这可能意味着由于您是从未知服务器调用,因此 Google 未授权。
可能的解决方案
- 转到https://console.cloud.google.com/ .
- 创建 new project并记下项目编号。
- 启用Apps Script API .
- 设置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.
- 从脚本更改 Apps 脚本默认项目:
- 确保 list 中的范围配置正确。
- 保存新版本并重新部署。
您可能需要创建一个新的 Apps 脚本,复制代码,将其链接到云项目,然后进行部署
引用文献
关于google-apps-script - 当从部署的公司项目调用 google script web app url 时,得到 java.io.IOException : Server returned HTTP response code: 403 for URL:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64606240/