Search code examples
google-apps-scriptgmail-addons

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 ?


Solution

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