Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You do not have permission to call showSidebar #18

Open
oshliaer opened this issue Jul 13, 2018 · 5 comments
Open

You do not have permission to call showSidebar #18

oshliaer opened this issue Jul 13, 2018 · 5 comments

Comments

@oshliaer
Copy link
Owner

To allow this add the next scope to appsscript.json

{
  "oauthScopes": [
    "https://www.googleapis.com/auth/script.container.ui"
  ]
}
@VAggrippino
Copy link

Adding the oauthScopes didn't work.

@oshliaer
Copy link
Owner Author

@VAggrippino , could you share a sample?

@VAggrippino
Copy link

Sure. I appreciate you taking a look.

It works if I run the function from the script editor, but not if I run it from the onOpen() handler.

Here's the error message in the StackDriver Logging:

Exception: You do not have permission to call Ui.showSidebar. Required permissions: https://www.googleapis.com/auth/script.container.ui
   at onOpen(Code:5:8)

Here's some very basic sample code recreating the problem:

function onOpen() {
    const html = HtmlService.createHtmlOutputFromFile('Index');
    const ui = SpreadsheetApp.getUi();
    ui.showSidebar(html);
}

and my appsscript.json:

{
  "timeZone": "Asia/Hong_Kong",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "oauthScopes": [
    "https://www.googleapis.com/auth/script.container.ui"
  ]
}

And the spreadsheet this is bound to is here

@VAggrippino
Copy link

Never mind... The problem is onOpen(). I apparently can't show any kind of Ui without user interaction: https://issuetracker.google.com/issues/69238694#comment7

@oshliaer
Copy link
Owner Author

@VAggrippino Thanks for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants