I want general profile information of user like birthdate, gender, username,etc. I am able to get email and unique profile id of user by using getProfileUserInfo
method of identity api.
It returns only email and id like this:
userinfo Object {email: "[email protected]", id: "1xxxxxxxxxxx49189xx"}
How do I get additional information?
I want general profile information of user like birthdate, gender, username,etc. I am able to get email and unique profile id of user by using getProfileUserInfo
method of identity api.
It returns only email and id like this:
userinfo Object {email: "[email protected]", id: "1xxxxxxxxxxx49189xx"}
How do I get additional information?
Share Improve this question asked Oct 16, 2015 at 5:50 Harshil PansareHarshil Pansare 1,1472 gold badges13 silver badges38 bronze badges 2-
chrome.identity
seems to be used for authentication purposes, not for whatever it is you want to do with personal info – Jaromanda X Commented Oct 16, 2015 at 6:00 - So how do I get users other information? So far, I have authToken and unique userID. – Harshil Pansare Commented Oct 16, 2015 at 6:04
1 Answer
Reset to default 9Although I am not sure about birthday, but you can get user's information like id
, name
, given_name
, family_name
, link
, picture
, gender
, locale
.
Code:
chrome.identity.getAuthToken({
interactive: true
}, function(token) {
if (chrome.runtime.lastError) {
alert(chrome.runtime.lastError.message);
return;
}
var x = new XMLHttpRequest();
x.open('GET', 'https://www.googleapis./oauth2/v1/userinfo?alt=json&access_token=' + token);
x.onload = function() {
alert(x.response);
};
x.send();
});
Just make sure you add the url
under scopes
in manifest.json
:
"oauth2": {
"client_id": "XXXXX",
"scopes": [
"https://www.googleapis./auth/userinfo.email"
]
}