Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get Active user's email

I tried to log the user's email for debugging purposes. I used Session.getActiveUser().getEmail(). I received the following error.

Exception: You do not have permission to call Session.getActiveUser.getEmail() Required permissions: https://www.googleapis.com/auth/userinfo.email

Hence i added the https://www.googleapis.com/auth/userinfo.email scope to my addon. Now I get the following error

The script does not have permission to get the active user's identity.

However, I don't see the error if I run it on my account(Gsuite) or any other users in our domain. FYI: I am the owner of the addon.

Am I missing any scopes ?

like image 926
hhsb Avatar asked Dec 21 '18 06:12

hhsb


2 Answers

Replacing getActiveUser() by getEffectiveUser() seem to make it work.

like image 88
hhsb Avatar answered Oct 12 '22 09:10

hhsb


I think the best explanation is in the official docs. Addon users context does not assume obligatory authorization and getEmail method may return a blank string.

like image 25
Александр Ермолин Avatar answered Oct 12 '22 09:10

Александр Ермолин