Reputation: 11
I need to execute a Google apps script web service on behalf of a user that is logged to my system. So I have her/his access token. I would like somehow to transfer the token to the web app and without having to authorize again the user to use it for some activities. Can this be accomplished?
We authorize a user visiting our website using OAuth2 and Google;
We get hold of her/his access token that Google returns;
There is a Google Apps Script web app that is executed as the user (write files in google drive user's folder)
running the web app;
We want to call this app (3) (not by redirecting the user to it but by calling it as a web service) by providing the access token (2) so Google not to ask again for authorization;
Thanks
Upvotes: 1
Views: 2386
Reputation: 3845
As far as I know, you can only get the access token from the current session but there is not function to set it.
You can send the access token as parameter to appsscript web service, but at the end you will have to call Drive API using the UrlFetch to make the call to the endpoints.
If you try to use the Driveapp service from appsscript, the requests will go against the effective User, which in the case of the webapp it would be the owner and the files will be created only in that account.
In your website, you already have code to obtain the access token, I would recommend to call the Drive Api directly from your website in order to perform all the necessary actions.
Upvotes: 0