虽然我不知道生日,但你可以得到用户的信息,如id
,name
,given_name
,family_name
,link
,picture
,gender
,locale
。
代码:
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();
});
只要确保你在manifest.json
添加url
scopes
下:
"oauth2": {
"client_id": "XXXXX",
"scopes": [
"https://www.googleapis.com/auth/userinfo.email"
]
}
来源
2015-10-16 09:30:22
Sid
'chrome.identity'似乎是用于认证目的,而不是不管它是你想要处理个人信息 –
那么如何获得用户其他信息?到目前为止,我有authToken和唯一的用户ID。 –