Search code examples
templatesgoogle-apps-scriptgoogle-docssidebar

Google Apps script Authorization from sidebar


Hi I have a script I am writing for a Google Docs template which includes a tutorial and some buttons to click for running scripts (some of which involve moving docs or folders and therefore require authorization).

The issue is when I try and run scripts through the sidebar, the authorization window doesn't pop up the way it does if I had made the request via a custom menu. I would really like to use the sidebar instead of the menu as it looks a lot nicer and allows me to include pictures for the tutorial. I have a button in the sidebar with this code:

<button class="create" onclick="google.script.run.addToDrive()">Add to Drive</button><br> 

But to make this work I have to have a redundant menu that runs the same function first so it can be authorized. Is there a better way?

thanks!


Solution

  • Are you using the new Docs and New Spreadsheets? Can you paste some code?

    When I want to force to appear the Authorization Window, sometimes I make a "foo function empty" as:

    function foo(){
      return 1;
    }