Authentication Passport Google oauth2不返回电子邮件
我试图使用passport google oauth2访问用户详细信息,它返回Authentication Passport Google oauth2不返回电子邮件,authentication,passport.js,passport-google-oauth2,Authentication,Passport.js,Passport Google Oauth2,我试图使用passport google oauth2访问用户详细信息,它返回id,gender,displayName,name,提供者,但不返回电子邮件 passport.use(new GoogleStrategy({ clientID: '1050835058852-cmniek05f0tdotj4ikp54s8qvvgbd9j4.apps.googleusercontent.com', clientSecret: 'LjnSZOwA95bL6hvKMYjWPc_Q', ca
id
,gender
,displayName
,name
,提供者
,但不返回电子邮件
passport.use(new GoogleStrategy({
clientID: '1050835058852-cmniek05f0tdotj4ikp54s8qvvgbd9j4.apps.googleusercontent.com',
clientSecret: 'LjnSZOwA95bL6hvKMYjWPc_Q',
callbackURL: 'http://localhost:3000/auth/google/callback',
profileFields: ['id', 'email', 'gender', 'displayName', 'name', 'provider']
},
function(accessToken, refreshToken, profile, cb) {
if (profile) {
user = profile;
console.log(profile);
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
return cb(null, user);
}
else {
return cb(null, false);
}
}
));
在我指定的配置文件字段中,它仍然发送除电子邮件以外的所有内容
这是我正在尝试验证的get请求
app.get('/auth/google',
passport.authenticate('google', { scope: ['profile'] })
);
app.get('/auth/google/callback',
passport.authenticate('google', { failureRedirect: '/auth/google' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/account');
});
我想在这个问题上保持沉默就是答案。。。我在想同样的事情这能回答你的问题吗?