为什么我部署为 API 可执行文件的应用程序脚本返回权限被拒绝? [英] Why does my apps script deployed as API executable return Permission Denied?

查看:13
本文介绍了为什么我部署为 API 可执行文件的应用程序脚本返回权限被拒绝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在脚本编辑器中创建了一个脚本,并将其发布为部署为 API 可执行文件".在这个脚本中,我为我的工作表提供了一个 doc_id 并定义了一个函数来从该工作表中获取数据.

I created a script in the script editor, published it as a "Deploy as API executable". Inside this script, I provided a doc_id to my sheet and defined a function to get data from that sheet.

然后我去了 https://developers.google.com/apps-script/execution/rest/v1/scripts/run 来测试执行 API.我添加了范围,授权了应用程序并尝试了它.我收到以下错误消息:

I then went to https://developers.google.com/apps-script/execution/rest/v1/scripts/run to test the execution API. I added the scopes, authorized the app and tried it. I am getting the following error message:

"error": {
  "code": 403,
  "message": "The caller does not have permission",
  "status": "PERMISSION_DENIED"
}

谁能告诉我我做错了什么?

Can someone tell me what I am doing wrong?

推荐答案

确保应用脚本与正确的开发控制台项目相关联.

Make sure the app script is associated with correct dev console project.

该脚本应与与使用的 OAuth 2.0 客户端 ID 对应的开发控制台项目 ID 相关联(此开发控制台项目还应启用Apps Script Execution API").

The script should be associated with the dev console project id that corresponds with OAuth 2.0 client ID used (this dev console project should also have "Apps Script Execution API" enabled).

要更改应用脚本的开发者控制台项目,请选择以下菜单项:资源 > 开发者控制台项目...

To change the developer console project for an app script select the following menu item: Resources > Developer Console Project...

在此屏幕上输入开发控制台的项目编号.

On this screen enter the project number for your dev console.

这篇关于为什么我部署为 API 可执行文件的应用程序脚本返回权限被拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆