简体   繁体   English

新的 API 后 Google 工作表脚本访问丢失 - 尝试使用工具时出错 -> 脚本编辑器

[英]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.

相关问题 Google Apps 脚本错误的第二个冒号后面的数字是多少? - What is the number after the second colon on a Google Apps Script error? Google Apps Script PropertiesService - 被不可靠的执行日志记录和编辑器调试搞糊涂了 - Google Apps Script PropertiesService - Confused by unreliable Executions logging & editor debugging Microsoft脚本编辑器(MSE)下载 - Microsoft Script Editor (MSE) download 谷歌脚本你可以使用 IDE 调试器逐步调试一个调用的谷歌脚本库吗 - google script can you use the IDE debugger to step through debug a called google script library Chrome开发者工具:缺少脚本标签 - Chrome Developer Tools: missing Script tab 在chrome dev工具中调试本地nodejs脚本 - Debugging local nodejs script in chrome dev tools 禁用chrome开发人员工具中的脚本编辑 - Disable script editing in chrome developer tools XP Home上的Internet Explorer的Microsoft脚本编辑器? - Microsoft Script Editor for Internet Explorer on XP Home? 脚本错误:“页面上的脚本发生错误” - Script error: “An error has occured in the script on the page” 在 Google Apps 脚本中,使用新的 V8 运行时时断点的工作方式是否有所不同? - In Google Apps Script do breakpoints work differently when using the new V8 runtime?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM