Search code examples
google-apps-scriptgoogle-authentication

How do I allow access to my Google webapp that writes to a Google Drive Spreadsheet


Edit: Issue Resolved

After much effort I started from scratch with a very simple script that wrote to a spreadsheet and accessed an external source. I believe my issue was one of not copying the correct deployment links and the sequence of running my tests, /dev vs /exec. Bottom line operator error. Thanks to those who helped.

When publishing the webapp I have selected Execute as Me and Allow access to: Anyone even anonymous. In Chrome, the webapp works fine when I'm logged in as myself obviously, and writes to the spreadsheet. However if I login under a different email, in one of the tabs, or non logged in, it brings up the Google Request access login screen. Same when I launch it in Chrome on an Android phone. Interestingly it works fine and writes to the Google Spreadsheet if I run it in a Safari browser without being logged into a Google account. So I must have the permissions correct. How can I get it to run on any device without the user needed to request access the the Spreadsheet? Here is the appscript.json manifest file:

{
  "timeZone": "America/New_York",
  "dependencies": {
  },
  "webapp": {
    "access": "ANYONE_ANONYMOUS",
    "executeAs": "USER_DEPLOYING"
  },
  "exceptionLogging": "STACKDRIVER"
}

Solution

  • You just need to re publish it with new project version. 1. Click pulbilsh 2. Deploy as web app 3. Change project version to new 4. Publish it