how to get userId of current user?

843 views
Skip to first unread message

Michael Hosford

unread,
Nov 2, 2016, 11:09:27 PM11/2/16
to InboxSDK
Is there a way to get the Google user ID of the currently active gmail account?  It appears to be used by InboxSDK internally-- can we have a "getter" method for it?

Thanks in advance.

Michael

Chris Cowan

unread,
Nov 3, 2016, 1:36:28 PM11/3/16
to InboxSDK
Is sdk.User.getEmailAddress() what you're looking for?

Michael Hosford

unread,
Nov 6, 2016, 7:28:55 PM11/6/16
to InboxSDK
Sorry, I should have been more specific.  I know about sdk.User.getEmailAddress() -- I was planning to use it to retrieve the email address, but I wanted to be able to fetch an oAuth2 token to access that user's account via Gmail API.  My original plan was to use chrome.identity.getAuthToken() to do this, and according to the docs, you have to use the "GAIA id" for the account if you want to specify an account other than the "primary account for the profile".  I could see my account id in various places in InboxSDK's data stashes, but didn't feel confident that trying to fish it out would be a reliable solution.

Since posting the question, I have become increasingly certain that I won't be able to use chrome.identity for this.  For my application, I will always need an oAuth2 token for the user logged into Gmail (sometimes more than one at a time), and I don't care who is logged into Chrome.  However, I did find Boris Smus' oAuth2 library on GitHub, which looks like it can easily be adjusted to do what I need.  Oddly, he has deprecated it in favor of chrome.identity -- hard to believe there wouldn't be more folks with the same multi-account needs, but maybe I'm missing something...

So-- thanks anyway.  :)

Michael
Reply all
Reply to author
Forward
0 new messages