11

I am trying to get email and id of user through chrome identity api.

I am doing this

  chrome.identity.getProfileUserInfo(function(userinfo){
    console.log("userinfo",userinfo);
    email=userinfo.email;
    uniqueId=userinfo.id;
  });

I have specified identity permission and have added https://www.googleapis.com/auth/userinfo.email in scopes.

User is logged in through chrome.identity.getAuthToken and I have access token.

console.log("userinfo",userinfo); returns userinfo Object {email: "", id: ""}

2 Answers 2

21

The getProfileUserInfo documentation says:

  • email: Empty if the user is not signed in or the identity.email manifest permission is not specified.
  • id: Empty if the user is not signed in or (in M41+) the identity.email manifest permission is not specified.

Edit manifest.json to include both permissions:

"permissions": ["identity", "identity.email"]
1
  • 1
    adding indentity.email permission helped Oct 16, 2015 at 5:17
8

In addition to having the identity.email permission, as posted in the related Chrome issue for this subject, users must have their profile syncing turned on under chrome://settings -> People -> Sync for their ID and email to show up using chrome.identity.getProfileUserInfo.

4
  • I've the same problem with me. By the time, the user accepts the sync-in, the event has been fired (or listened) and the email_id returned is empty. Any resolution to this? May 27, 2019 at 19:50
  • I would guess not besides them refreshing the page or whatever that is calling it. May 27, 2019 at 23:13
  • 4
    You can add {accountStatus: 'ANY'} as the first parameter to getProfileUserInfo, the default is 'SYNC'.
    – mal
    Oct 1, 2021 at 6:04
  • @mal's suggestion was the key for me.
    – Zach
    Jan 24 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.