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 :
- The user authenticates on my web App on his Google Account
- He clicks on a button to send an email
- If he never gave the authorization to my Google Apps Script, the authorization popup is displayed
- He grants permissions, he is not redirected to the Google Apps Script result page, but stays on my web app
- The Google Apps Script sends the email, and returns something in JSONP to my Web App.
Is it possible to do that ?
I have thought of several solutions but I don't know how to make them work :
- Is there a way to set the Google Apps Script' s client_id to be the same as my Web App ?
- Or is there a way to create (& customize) the button which is automatically generated when I try to access a Google Apps Script to which I have not granted access, and display that button on my web app ?
I am stuck with this, any help much appreciated !