从 id_token Gmail OAuth 获取电子邮件
Get Email from id_token Gmail OAuth
我有一个包含以下详细信息的 JSON 对象:
{ access_token: 'access_token',
token_type: 'Bearer',
expires_in: 3599,
id_token: 'longstring'
}
使用 NodeJs 库 'googleapis' 如何获取上述回复的电子邮件地址。我不想使用 URL: https://www.googleapis.com/oauth2/v1/userinfo?access_token=your_access_token
像在 introduction, and then you can use the getProfile 方法中一样获取 auth-object:
function getEmailAddress(auth, callback) {
gmail.users.getProfile({
auth: auth,
userId: 'me'
}, function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
callback(err, null);
} else {
callback(null, response.emailAddress)
}
});
}
我有一个包含以下详细信息的 JSON 对象:
{ access_token: 'access_token',
token_type: 'Bearer',
expires_in: 3599,
id_token: 'longstring'
}
使用 NodeJs 库 'googleapis' 如何获取上述回复的电子邮件地址。我不想使用 URL: https://www.googleapis.com/oauth2/v1/userinfo?access_token=your_access_token
像在 introduction, and then you can use the getProfile 方法中一样获取 auth-object:
function getEmailAddress(auth, callback) {
gmail.users.getProfile({
auth: auth,
userId: 'me'
}, function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
callback(err, null);
} else {
callback(null, response.emailAddress)
}
});
}