简体   繁体   中英

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. When I try, Google opens up the standard "Access Denied" - "Request Access" error page. 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.

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. 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"). I would guess that the same problem that prevents the Script editor working from the Sheet is also preventing the API debugger working properly.

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.

Problem resolved by logging out of both my Google accounts and logging back in with my work account. I think this must be some sort of Google Bug.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM