I've just published my addon to G Suite Marketplace for the first time :D
(After about 2 weeks, Google had published our addon today)
And the first thing that I noticed is: A lot of bugs :(
Although I had tested my code with my bound document very carefully.
Those bugs related to this line of code:
Session.getActiveUser().getEmail()
It always returns an empty string, though I had OAuth permission for https://www.googleapis.com/auth/userinfo.email
I guess (but can't be sure) that I need to use this function instead:
Session.getEffectiveUser().getEmail()
I can't be sure because I had updated the code and submitted a new version to G Suite Marketplace but Google didn't publish it yet (maybe because the migration from Addon Store to G Suite Marketplace is still unstable)
So do you have experience with Addon on G Suite Marketplace about this problem?
Should I use getEffectiveUser()
instead of getActiveUser()
all the time ?
EDIT:
This is the context of the code that runs Session.getActiveUser():
- After the user has accepted the OAuth permissions
- The sidebar appeared
- The client-side code call functionX (that has a call to Session.getActveUser()) using
google.script.run.functionX...
According to this guide https://developers.google.com/gsuite/add-ons/concepts/editor-auth-lifecycle#authorization_modes, when using google.script.run, the AuthMode is FULL
AuthMode.FULL
, that explains the empty string being returned. – chuckx