google-apps-script - 当从部署的公司项目调用 google script web app url 时,得到 java.io.IOException : Server returned HTTP response code: 403 for URL:

标签 google-apps-script http-status-code-403 google-workspace

我已经使用我的个人谷歌帐户在谷歌脚本中创建了一个项目。我将其部署为网络应用程序,并授予任何人(甚至匿名)访问权限,并且可以身份执行该应用程序。我在我为公司工作的项目中使用了部署的谷歌脚本网络应用程序网址。当我从本地主机调用 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 未授权。

可能的解决方案

  1. 转到https://console.cloud.google.com/ .
  2. 创建 new project并记下项目编号。
  3. 启用Apps Script API .
  4. 设置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 脚本默认项目:
  • enter image description here

    enter image description here

  • 确保 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/

    相关文章:

    php - 模拟 403 错误页面

    google-apps-script - Google Chat bot - 发送没有事件的私有(private)消息

    javascript - 如何使用 Google App 脚本根据条件发送带有 PDF 文件附件的电子邮件

    google-apps-script - 使用google脚本和查询功能构建google图表

    sql - 如何在 Data Studio BigQuery 社区连接器的 SQL 查询中包含日期范围

    image - Google 驱动器图像给出 403 禁止错误

    android - 尝试使用 JRAW 检索 Reddit 用户保存的帖子时出现 403 错误

    javascript - 照片上传的描述框输入

    json - 使用 Google Enterprise License Manager API 插入 G Suite licenseAssignment 时出现错误 400 "Invalid JSON payload"

    java - 如何通过 GMail API 使用 GSUITE 组 ID 发送电子邮件?