4
votes

I created a Google Apps Script project that is published as a WebApp visible for anyone, running as the accessing user.

This WebApp includes a Library project, which has methods to access ScriptDb as following:

function getDb() {
  return ScriptDb.getMyDb();
}

function save(props) {
  return getDb().save(props);
}

I intend to have one WebApp running per accessing user (using time-based triggers to access Gmail), however I would like to use the ScriptDb to store data independently from the user running the WebApp. So I thought the chapter Centralizing a Place to Get a Database Instance from the Google Apps Script Documentation applies here, however I am getting the following error when accessing the WebApp:

You do not have access to library MyDBLibrary, used by your script, or it has been deleted.

Am I doing anything wrong? Was ScriptDb not intended to run independently of the user, when being accessed from a WebApp?

2

2 Answers

4
votes

Joscha - you have the set up right and I reproduced everything you've reported. The last thing you were missing was to the share the Library project itself to the public.

The way to do that is to 1. Open the Library project in the script editor 2. Go to File -> Share 3. In the "Who has access" section, set it to anyone with the link can View (dont need edit).

Sharing settings

Without this, Apps Script will now know its ok to serve the library code to the public. Hope this helps.

-1
votes

You may need to turn on development mode flag to make it work.

Here's what I did.

  1. User A: Created a Master spreadsheet and created an app script and saved it with version 1.0.
  2. User A: Gave access to this sheet to user B so they can use the common app script.
  3. User A: Gave project access key to user B. 4.User B: Created a spreadsheet and added resource library with project key.
  4. User B: Selected version 1.0.
  5. User B: Turned on development mode.

Note: if I follow steps 1 through 5, then I still see the same error saying I don't have permission or the script has been deleted. However, also doing step 6 will resolve the error and allow you to use the shared script.