Retrieve authenticated users email address

Skip to first unread message


Aug 8, 2020, 1:51:05 PM8/8/20
to Google Apps Script Community
Hello everyone,
I am new to Google App Scripts, so if this is obvious, I apologize.  But, I have been searching online and have not found anything.  I have a Google Sheet that has a web app associated.  I want to protect the sheet (only allow myself or designated others in my organizations domain) directly interact with the sheet. But, I want to allow anyone from the public access the site (even if they are not logged into Google).  But, if they are logged into their Google Account (on our domain or in the public) I would like to allow that as a form of authentication to the Google web app, and capture their username.  My Web App is deployed with the following configuration:

1.  Execute the web app as :  me (
2.  Who has access to the app:  Anyone

To test, I login to Google with my personal account.  If I go directly to the Google Sheet, I can view it but it is read only (which is fine).  If I then visit the Google App web page, I can effectively interact with the web page (which reads and writes to the google sheet).  But, when I use the following code, I do not get a response I expect:

  var activeuser= Session.getActiveUser();  //returns nothing
  var userEmail = Session.getEffectiveUser().getEmail(); //returns the username of who the script is executed as (, not the personal actually logged into Google.

Is there a way to capture who is actually logged into Google?  But, making sure no one can directly write to the Google Sheet, except for myself or someone I give specific access too?  Hope that makes sense.  If not, please let me know.


iBO • App Service

Aug 13, 2020, 7:29:44 PM8/13/20

Am Sa., 8. Aug. 2020 um 19:51 Uhr schrieb DreamDelerium
> --
> You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> To view this discussion on the web visit



Reply all
Reply to author
0 new messages