Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
962 views
in Technique[技术] by (71.8m points)

google apps script - ScriptDb in Library accessed by WebApp

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...