CURRENTLY
I want to collect the user email of users accessing my Google Apps Script webapp.
To achieve this I set Execute as "Me", with Who has access: "Anyone with Google account"
function doGet(e) {
let userEmail = Session.getActiveUser().getEmail()
return HtmlService.createHtmlOutput(
"<!DOCTYPE html><html><body>Email: "+userEmail+"</body></html>"
);
}
The deployment then has an EXEC link created:
https://script.google.com/macros/s/1234................56789/exec
ISSUE
When the execution link is accessed by a user in Incognito window, IE, or Firefox, the user is asked to log in on Google.
After the user logs in, the page returns:
Email:
WHAT I WANT
- User access
exec
link, and is prompted to log into google - After logging into google, user receives HTML:
Email: [email protected]
NOTES
I recently tried adding:
"oauthScopes": [
"https://www.googleapis.com/auth/userinfo.email"
],
but this had no effect.