Google Apps Script – Authorization Needed Error in Dummy Web App

google-apps-script

I'm trying to write a Google Apps Script web app, which will, eventually, populate a spreadsheet. However, I'm having a hard time getting started.

I have an HTML file:

<div>
  <select name="player1"></select>
  <input type="number" name="score1"/>
  <select name="player2"></select>
  <input type="number" name="score2"/>
</div>

and a script file:

function doGet() {
  return HtmlService.createTemplateFromFile('myHtmlFile.html').evaluate();
}

I have published it as a web app (Publish -> Distribute as web app -> Update), and set the app to run as myself, with only myself allowed to access it.

After that, clicked the link to "test your newest code".
However, this link gives me nothing but the message "Authorization is necessary to perform this action" (translated).

How can I perform this authorization, and why is it necessary (as I'm running the app as myself, with access only to myself)?

Best Answer

Found the solution here: https://stackoverflow.com/questions/11421055/how-do-i-stop-the-error-authorisation-is-required-to-perform-that-action-in-goo

It is also mentioned in the official documentation: https://developers.google.com/apps-script/troubleshooting#common_errors

In short:

  1. In the Script editor, run the doGet function from the dropdown menu

  2. An authorization popup shows

  3. Grant access

  4. Re-run the app from the "latest code" link, and you should not get the authorization error