Reputation: 5821
When you reference a library, the pre-approved authorizations on it do not get passed and so the caller script has to re-authorize.
For example, if I:
Then, if someone else reference's it as a library in another script and calls that function, it will require them re-authorize and then it will execute GmailApp
under their Google identity.
Is there a way to make it so caller scripts can call my library functions and have them run under my identity?
Upvotes: 0
Views: 30
Reputation: 2288
It is not possible to have a function that run with your credentials, Apps Script always run with user credentials that execute the script. Functions call from a library are just an extension of the current script, that is why user need to authorize the script.
Only way to have a script that run with your credentials is to publish the script as a web app and select to run with your credentials. By this way a user can execute the script as you but you will not to build a custom web interface.
Reference : https://developers.google.com/apps-script/guides/web
You can also imagine to use the OAuth 2 library by setuping a custom authentication system but it is a bit more tricky.
Stéphane
Upvotes: 3