[英]Google sheet script access lost after new API - error trying to use Tools -> Script editor
I have just returned to do some maintenance on Google sheet scripts I wrote last year and I can't get in to debug them from the Sheet's Tools -> Script editor command.我刚刚回来对我去年编写的 Google 表单脚本进行一些维护,但我无法从表单的工具 -> 脚本编辑器命令中调试它们。 When I try, Google opens up the standard "Access Denied" - "Request Access" error page.当我尝试时,Google 会打开标准的“拒绝访问”-“请求访问”错误页面。 The same problem seems to affect every Sheet I have with an embedded script.同样的问题似乎影响了我使用嵌入脚本的每张工作表。 I suspect this is a side-effect of being upgraded to the new scripting API.我怀疑这是升级到新脚本 API 的副作用。
I can still run the scripts normally and they operate as expected.我仍然可以正常运行脚本并且它们按预期运行。
I can open the scripts from the new API Console and I can edit them successfully from there.我可以从新的 API 控制台打开脚本,然后我可以从那里成功编辑它们。 However if I try to run the scripts with the debugger from the API console, I get an immediate error when the script tries to access the Sheet data it looks like the SpreadsheetApp.getActiveSpreadsheet is not returning a useful value (debugger says "select active spreadsheet first").但是,如果我尝试使用 API 控制台中的调试器运行脚本,当脚本尝试访问工作表数据时,我会立即收到错误,看起来 SpreadsheetApp.getActiveSpreadsheet 没有返回有用的值(调试器说“选择活动电子表格第一的”)。 I would guess that the same problem that prevents the Script editor working from the Sheet is also preventing the API debugger working properly.我猜想阻止脚本编辑器从工作表工作的相同问题也会阻止 API 调试器正常工作。
I am sure the code itself is fine as it works without the debugger.我确信代码本身很好,因为它没有调试器就可以工作。
Surprisingly, just after posting this question I seem to have found the answer.令人惊讶的是,在发布这个问题之后,我似乎找到了答案。 It appears that the Google Sheet's Tools -> Script editor command used my default (home) Google account, even though I was logged into my work account and had successfully loaded the Sheet which I can only access from my work account.尽管我已登录到我的工作帐户并已成功加载我只能从我的工作帐户访问的工作表,但 Google 工作表的工具 -> 脚本编辑器命令似乎使用了我的默认(家庭)Google 帐户。
Problem resolved by logging out of both my Google accounts and logging back in with my work account.通过注销我的两个 Google 帐户并使用我的工作帐户重新登录解决了问题。 I think this must be some sort of Google Bug.我认为这一定是某种 Google 错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.