1
votes

My apps scrip web app is deployed as "execute as me"; this is important, as I don't want users to have to authenticate and trust a script not to read their private Google data. Right now, users don't get any authentication message and I want to keep it that way.

I would like to grab the user's email address when they load the site, in order to personalize some of the content. Obviously I can't use Session.getActiveUser().getEmail(), as that returns my email every time (as it's running as me). Creating other web apps and using FetchUrl won't help, as at some point the user will have to authenticate, which I'm trying to avoid.

One fairly non-intrusive solution would be to get the user to enter their email address as a one-off action when they first try to use the part of site that I want to personalize. However, I would need to store that somewhere locally I guess.

So, just wondering if there are any possibilities to help me do this? e.g. can GAS use cookies or some other permanent(ish) local storage that the app could read the next time the user loads the page?

All my users are on the same domain (non-gmail).

Appreciate you listening. Thanks in advance!

1
There’s PropertiesService, Spreadsheets, Files, Databases take your pick.Cooper
If by locally you mean your computer. Then with a script and no user interaction then probably not. Even a cookie requires your browser to be on.Cooper
Thanks Cooper for the quick response. Basically I'm happy storing the email address anywhere that would enable the script to pick it up when the script is next accessed by the same user (same machine). Even within the same browser session would be OKish. Just so there's a way to link machine/user to script execution. The problem with running the app "as me" is that I've lost that link and I'm looking for some hacky way of reestablishing it (to some extent).Jamie C
What keeps users from entering some else’s emailCooper
Nothing; they would get that user's data. But there's no privacy problem here - all data is shared. My app doesn't read any private data.Jamie C

1 Answers

0
votes

What you want cannot be achieved essentially because you plan on gathering the user's data without them actually authorizing it by giving the consent.

The same goes with storing the data and remembering it specifically for each user.

As far as authorization goes, you can always choose the most restrictive scope when building a web app.