google-apps-script - 通过 postman 向 Google Apps Script API 发出请求

标签 google-apps-script google-cloud-platform postman http-status-code-403 google-apps-script-api

我正在尝试通过 postman 请求使用应用程序脚本 API 远程执行 Google 应用程序脚本函数。

我首先从 Google API Playground 获取凭据

然后它们作为 OAuth2 凭据输入到 postman 中,并输入到 header 中,如下所示: enter image description here

然后请求适当的链接: enter image description here

然后 body 准备好了: enter image description here

然后是发出请求后的响应: enter image description here

Postman 返回错误 403,根据 Google's documentation

表示“授权请求时使用的云平台项目与脚本使用的云平台项目不同。”错误 403 是一个授权错误,可能意味着很多事情,但我们假设该错误就是 google 宣称的那样。

我可以完全控制我的脚本使用的 GCP 项目,但我不知道在哪里可以找到用于授权请求的项目。

我可以在哪里获得此 GCP 项目的访问权限,以便将我的脚本分配给此项目,从而消除 403 错误?

谢谢!

最佳答案

要将 OAuth Playground 中的 OAuth 访问 token 与 Apps 脚本结合使用,您需要在同一项目中指定正确的客户端 ID 和客户端 key 。

在 OAuth Playground 中。单击齿轮图标(右上角)。选择“使用您自己的 OAuth 凭据”。然后输入在与 Apps 脚本相同的项目中创建的客户端 ID 和 secret ID。

关于google-apps-script - 通过 postman 向 Google Apps Script API 发出请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56799212/

相关文章:

javascript - 在谷歌电子表格中搜索行的最佳方法

javascript - 如何将所有数组合并为一个

kubernetes - 仅具有内部网络的 VM 上的 GitLab Runner

firebase - Cloud Functions for Firebase Scheduler 的时区没有改变

google-apps-script - 如何转移管理员不拥有的文档的文件所有权?

jquery - Google Apps 脚本 HTML 服务中的 HTML5 表单验证和文件上传

google-cloud-platform - 导出 BigQuery 日志记录 : which resource types to select (and what is the difference between them? )

node.js - API Controller : Cannot PUT,无法删除(404未找到)

javascript - postman 测试抛出错误 : TypeError: Cannot read property 'ProjectNumber' of undefined

node.js - 使用 POST 请求传递 JSON 数据后,无法从 Postman 获取响应响应