因此,为了避免每次打开电子表格时都重新添加触发器,我想检查它是否已经存在。
来自the docs的我有
var ss = SpreadsheetApp.getActiveSpreadsheet();
var triggers = ScriptApp.getUserTriggers(ss);
所需的授权范围是:https://www.googleapis.com/auth/script.scriptapp
我已经像这样添加到appsscript.json中:
(...)
"oauthScopes": [
"https://www.googleapis.com/auth/forms",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/spreadsheets"
]
(...)
尽管我仍然遇到此错误(翻译自丹麦语):
You don't have permission to call
ScriptApp.getUserTriggers.
Required permissions:
https://www.googleapis.com/auth/script.scriptapp
at onOpen(get-form-submit-and-update-sheet:4)
我想念什么?
答案 0 :(得分:0)
在这里找到答案:https://stackoverflow.com/a/52276300/532238
添加
ScriptApp.invalidateAuth();
作为onOpen()函数的第一行。
让您重新授权-虽然对我来说似乎是一个黑客。