【发布时间】:2022-03-02 19:50:15
【问题描述】:
根据这篇文章https://auth0.com/docs/api/authentication#get-user-info,我可以获得用户信息。挑战在于,我获得的不是完整的用户信息,而是部分信息。
我在我的 JWT 中定义了 "scope": "openid profile email"。如何检索完整信息?我错过了什么吗?
代码:
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://YOUR_DOMAIN/userinfo',
'headers': {
'Authorization': 'Bearer {TOKEN}',
'Cookie': 'COOKIE'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
实际反应:
{
"email": "janedoe@exampleco.com",
"email_verified": true,
"name": "Jane Josephine Doe",
"nickname": "JJ",
"picture": "http://exampleco.com/janedoe/me.jpg",
"sub": "248289761001",
"updated_at": "1556845729"
}
预期响应:
{
"address": {
"country": "us"
},
"birthdate": "1972-03-31",
"email": "janedoe@exampleco.com",
"email_verified": true,
"family_name": "Doe",
"gender": "female",
"given_name": "Jane",
"locale": "en-US",
"middle_name": "Josephine",
"name": "Jane Josephine Doe",
"nickname": "JJ",
"phone_number": "+1 (111) 222-3434",
"phone_number_verified": false,
"picture": "http://exampleco.com/janedoe/me.jpg",
"preferred_username": "j.doe",
"profile": "http://exampleco.com/janedoe",
"sub": "248289761001",
"updated_at": "1556845729",
"website": "http://exampleco.com",
"zoneinfo": "America/Los_Angeles"
}
【问题讨论】: