2
votes

Is there any way to invoke a Google Apps Script which serves content and limited to a domain within another Google Apps Script which is invoked by a user who is in that domain? Basically the content serve script is something which runs on administrator of the domain and serves private information.

I think it should work when content serving script is made, available to anonymous usage, but I wanted the content serving script to be available only within domain.

3
have you seen this other post ? - Serge insas
I saw that post earlier, thats not exactly what I am looking for. - INCLUDE STDIO.H

3 Answers

4
votes

You could publish the first script as a web service, and then just call the functions remotely. This can be done because when you publish as a web application you set the permissions with which the script gets executed.

https://developers.google.com/apps-script/execution_web_apps

0
votes

Unfortunately, this isn't possible, as the script request aren't executed in the name of the author neither the user executing it, setting anonymous usage for the script should work.

But you can pass an argument through post or get. so even if anyone can invoke the script, only the script invoked with a key argument will do something

The question that remain is what to use: get or post I don't know if request made by the script are done in https, so it's maybe a better solution to use post.

0
votes

is a library what you're looking for? Remember this may slow down executions (vs just binding the script to multiple files like normal)

https://support.google.com/docs/thread/13371261?hl=en Yes, it is possible. The simplest solution is to create an Apps Script library. You can use either a standalone script or a bound script as the library. I prefer to use a standalone to make it easier to access, and you won't be able to use functions that are specific to bound scripts that could mess up your script.

HERE is a quick video demonstrating how to get a GAS library setup. https://www.youtube.com/watch?v=TqWtSp4IJcg&feature=youtu.be