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:
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 (
firstLett...@myorg.com), 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.
Thanks