【发布时间】:2020-05-29 09:49:20
【问题描述】:
我正在研究 Google Apps 脚本。我有我编写的应用程序脚本,应该由特定工作表上的onEdit 事件执行。
onEdit.gs
function onEdit(e) {
var syokuninIchiran = new SyokuninIchiran();
syokuninIchiran.syncTable();
}
当在sheet上通过edit执行上述操作时,会出现这个错误:
您无权调用 openById。所需权限:https://www.googleapis.com/auth/spreadsheets
但是,当脚本从 Google Apps 脚本开发窗口触发时,它可以正常工作。我通过如下的测试函数调用相同的代码:
function test(){
var syokuninIchiran = new SyokuninIchiran();
syokuninIchiran.syncTable();
}
这个问题可能有问题?电子表格的所有者不是我的。我的帐户有权编辑如下图。
尝试1:
我尝试将范围手动添加到清单文件中(appsscript.json)。我批准了授权。但是,什么都没有改变。它仍然有相同的错误消息。
{
"oauthScopes": [
"https://www.googleapis.com/auth/sqlservice",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/script.external_request"
]
}
【问题讨论】:
标签: google-apps-script google-sheets-api