我想通过策略获取使用 Passport.js 的用户的生日passport-google-oauth20。我从哪里获得这个额外范围的响应以及如何提取这些信息?
我在从用户那里提取个人资料和电子邮件方面取得了成功,但我尝试的所有其他范围似乎都找不到它返回的位置。我正在使用Google Identity Platform 中的一些范围(更具体地说,我已经从 Google Cloud Platform 激活了 People API)并且它们没有出现在 Passport 策略回调中(只有个人资料和电子邮件)。
这是我设置护照并检查返回的内容的地方
passport.use(
new GoogleStrategy(config, (accessToken, refreshToken, profile, done) => {
console.log(profile);
// outputs:
// id: ...
// displayName: ...
// name: { ... }
// emails: [ { ... } ]
// photos: [ { ... } ]
// _raw: ...
// _json: ... (above info plus profile link and locale)
...
})
);
Run Code Online (Sandbox Code Playgroud)
在我的路线中,我声明了范围并重定向用户
router.get('/auth/google/', passport.authenticate('google', {
scope: ['https://www.googleapis.com/auth/user.birthday.read', 'profile', …Run Code Online (Sandbox Code Playgroud) javascript node.js express passport.js passport-google-oauth2