Filippo
Filippo

Reputation: 320

Get user email without full permissions

I need to get the email of the user accessing the web app. The web app is embedded in a google site. I know how to do that with the following:

var email = Session.getActiveUser().getEmail();

However, that requires that the user grant permission to the script and the permission message is quite scary: it allows to send email on the user behalf, modify any of his/her google sheets, and so on.

Is there a way to avoid that wide range of permissions just to get the user email?

Update: my script also need to update a sheet, but does not have to be updated by the user. However, I need the user to run the app themself to get their email.

Upvotes: 0

Views: 845

Answers (1)

Wicket
Wicket

Reputation: 38349

The permissions referred in the question

it allows to send email on the user behalf, modify any of his/her google sheets, and so on.

aren't related to

Session.getActiveUser().getEmail();

According to https://developers.google.com/apps-script/reference/base/session#getactiveuser the above method only requires

https://www.googleapis.com/auth/userinfo.email

If you want a less "scary" permissions you should have to remove the methods that require them or set the oAuth scopes manually in the manifest and/or th oAuth consent page of your project.

Upvotes: 2

Related Questions