问题
I wrote a google scripts editor addon, and published it to the google marketplace with private visibility (it is only visible to the users in my organization). I tested the addon with all types of permissions (installed for current user, enabled in current document, installed and enabled) in the script editor, and everything works as intended. However, after publishing the addon to the marketplace and installing it in a test spreadsheet, I keep getting this error: We're sorry, a server error occurred while reading from storage. Error code PERMISSION_DENIED.
from the onOpen
function.
I am setting these oauth scopes explicitly:
"oauthScopes": [
"https://www.googleapis.com/auth/script.container.ui",
"https://www.googleapis.com/auth/spreadsheets.currentonly",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
]
And here is my onOpen
trigger:
function onOpen(e: AppsScriptEvent) {
if (e && e.authMode !== ScriptApp.AuthMode.NONE) {
const ui = SpreadsheetApp.getUi();
const menu = ui.createAddonMenu();
menu.addItem("Add New Offering", "addNewOffering");
menu.addSeparator();
menu.addSubMenu(
ui
.createMenu("Settings")
.addItem("Dashboard Name", "changeDashboardName")
.addItem("Dashboard Start Cell", "changeDashboardStartCell")
);
menu.addToUi();
}
}
What other type of permission am I missing here?
回答1:
I ran into the same problem and it seems to be related with being signed into multiple google accounts on Chrome.
- Laptop 1: Last night I was working on my Google App Script from my laptop which is only using one Google Account on Chrome.
- Laptop 2: Today I'm trying to update my Google App Script using my other laptop which has multiple Google Account's signed-in.
When running the script from Laptop 2 I get an error:
We're sorry, a server error occurred while reading from storage. Error code PERMISSION_DENIED.
I tried the script on Laptop 1 and everything was working fine. Next I opened an Incognito windows on Laptop 2 and signed into my single account and everything works.
回答2:
Disabling App Script V8 runtime fixed the issue for me when logged with multiple accounts...
I was developing an Add-on on my non-primary Google account so I was facing the error when calling server-side Google App Script functions from HTML Dialogs.
I hope that helps.
来源:https://stackoverflow.com/questions/60230776/were-sorry-a-server-error-occurred-while-reading-from-storage-error-code-perm