title: Force ask authorization onOpen() (force popup)
body: <p><strong>SUMMARY: Is it possible to ask for authorization onOpen()?</strong></p>
  
  <p>DETAILED VERSION:
  I have a spreadsheet with buttons that gets distributed to a lot of people.
  When any button is pressed, some functions that require permissions are called, so Google Apps Script shows this popup:</p>
  
  <p><a href="https://i.stack.imgur.com/ptAJW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ptAJW.png" alt="enter image description here"></a></p>
  
  <p>AFTER this is accepted, everything runs well, since it has authorization now. However, I want to run things that require permissions BEFORE a button is pushed, when the Workbook is opened. However, if you place authorization-requiring code into an onEdit or onOpen function, it runs with no privileges by default and crashes halfway, rather than showing the popup and asking for permissions.</p>
  
  <p>Here is some code that exemplifies this - crashing instead of asking for permissions to create a trigger (also works for CalendarApp, etc.):</p>
  
  <pre><code>function onOpen(e) {
    Browser.msgBox("This is shown to the user");
    try {
      ScriptApp.newTrigger('someFunction').forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet()).onEdit().create();
    }
    catch (e) {
      Browser.msgBox(e);
    }
    Browser.msgBox("This message is never shown to the user if there is no try catch because it crashes");
  }
  </code></pre>