Get authenticated user's name and avatar?

242 views
Skip to first unread message

Jody Heavener

unread,
Apr 16, 2015, 7:38:14 PM4/16/15
to chromium-...@chromium.org
Hi all, quick question: how would I use chrome.identity to get the logged-in / authenticated user's profile name and avatar?

I am able to authenticate with the profile scope using:

chrome.identity.getAuthToken({
  interactive: true,
  scopes: [ "profile" ]
}, (token) => {
  // token...
});

... which, of course, gives me an auth token.

And I can get the profile email/ID using:

chrome.identity.getProfileUserInfo((userInfo) => {
  console.log(userInfo)
});

... but that only returns the email and ID.

What steps should I take to get the user's name?

Jody Heavener

unread,
Apr 16, 2015, 8:00:35 PM4/16/15
to chromium-...@chromium.org
Got it:

chrome.identity.getAuthToken({
  interactive: true,
  scopes: [ "profile" ]
}, (token) => {
  let xhr = new XMLHttpRequest();
  xhr.onreadystatechange = () => {
    if (xhr.readyState === 4) {
      console.log(JSON.parse(xhr.response));
    }
  }
  xhr.send();
});
Reply all
Reply to author
Forward
0 new messages