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?
Although 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.com/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.com/auth/userinfo.email"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With