Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

We're sorry, a server error occurred while reading from storage. Error code PERMISSION_DENIED

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?

like image 723
Carlos Avatar asked Feb 14 '20 17:02

Carlos


Video Answer


1 Answers

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.

like image 153
Oswald Avatar answered Oct 18 '22 04:10

Oswald