Reputation: 2279
I need to access a Google Apps Script in AJAX that needs authorization from the user to send an email from his GMail Account. For various reasons, I have to send that email from the Google Apps Script.
The call is made from my web application hosted on my server. I am also using Google Signin+ Authentication. I tried to include gmail in the my web app authorization scopes, but it is not sufficient because my web App and my Google Apps Script are not the same entity for Google (not the same client_id).
I would like the whole thing to work as following :
Is it possible to do that ?
I have thought of several solutions but I don't know how to make them work :
I am stuck with this, any help much appreciated !
Upvotes: 0
Views: 616
Reputation: 19835
None of your options are possible. You cant bypass that authorization screen in any way.
Using the same clientid or scopes wont help you, at most that would authorize your account not the users account. Each user is an independent oauth flow with its own token saved by apps script.
However
If you must, its now possible to do it in a different way because:
1) apps script now supports (since feb 2014) implementing your own oauth2 flow.
See StateTokenBuilder/ScriptApp.getOAuthToken()/ScriptApp.newStateToken()
2) Google now offers an oauth2 gmail api (unveiled a few days ago at google I/O 2014)
with these two, you can make your own code to send emails using your own console project etc.
Upvotes: 1