Passport-Facebook身份验证不会为所有Facebook帐户提供电子邮件或其他信息(未定义)



我已经尝试了所有方法,但我无法从FB帐户获得任何其他信息。我只从我的脸书策略中获得显示名称和 id:

passport.use(new FacebookStrategy({
clientID        : configAuth.facebookAuth.clientID,
clientSecret    : configAuth.facebookAuth.clientSecret,
callbackURL     : configAuth.facebookAuth.callbackURL,
// profileFeilds   : ['id','displayName','email'],
passReqToCallback : true,
profileFeilds   : ['id', 'email', 'gender', 'link', 'locale', 'name', 'timezone', 'updated_time', 'verified'],
},
function( req,accessToken, refreshToken, profile, done) {
//console.log(profile);
console.log(JSON.stringify(profile));
done(null,profile);
}));

获取部分:

router.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
router.get('/auth/facebook/callback',
passport.authenticate('facebook', {
successRedirect : '/',
failureRedirect : '/blogs',
//scope:['email']
}));

输出:

{ id: '1233755832057029',
username: undefined,
displayName: 'John Maverick',
name:
{ familyName: undefined,
givenName: undefined,
middleName: undefined },
gender: undefined,
profileUrl: undefined,
provider: 'facebook',
_raw: '{"name":"John Maverick","id":"1223755832057029"}',
_json: { name: 'John Maverick', id: '1223755832057029' } }

更改此内容

router.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));

对此

router.get('/auth/facebook', passport.authenticate('facebook', { scope : ['email'] }));

并更改此内容:

profileFeilds

对此:

profileFields

相关内容

最新更新