Avinash
Avinash

Reputation: 11

Unable to access spreadsheet which is published to the web from appscript

I've written a app script(web app) to access spreadsheet and display it's content based on search criteria.

Web app should display content based on given name

It is working fine with my own gmail account. But when other users(given access for app script web app) tried this app they're seeing error as

"Exception: You do not have permission to access the requested document." It is throwing an error when SpreadsheetApp.openById(spreadsheetId) is executed.

By giving an explicit access(sharing with user) to the spreadsheet, he is able to access the data without any issue. But as spreadsheet is already published to the web to access by anyone, why should it required again an explicit access to execute spreadsheet.

Is there way to access spreadsheet data without sharing it with the end user? Thank you in advance for the help.

Upvotes: 1

Views: 110

Answers (1)

Jacques-Guzel Heron
Jacques-Guzel Heron

Reputation: 2598

I understand that you published a web app that opens a certain Sheet. In the "Deploy as web app" menu (opened from the Apps Script editor and selecting Publish ⮞ Deploy as web app) you would have been asked to determine how to "Execute the app as". You can choose between these values:

  • Me: every web app user will open the Sheet as yourself.
  • User accessing the web app: every web app user will open the Sheet as themselves.

As a consequence of the second case, the users would need previous access to be able to open the Sheet. Since you want to give them access no matter what, I recommend to use the first option. Please, ask me any additional doubt.

Upvotes: 0

Related Questions