Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension identity.email empty

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: ""}

like image 249
Harshil Pansare Avatar asked Oct 15 '15 20:10

Harshil Pansare


2 Answers

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.

like image 177
Zach Saucier Avatar answered Oct 03 '22 21:10

Zach Saucier


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"]
like image 30
wOxxOm Avatar answered Oct 03 '22 21:10

wOxxOm