我已尝试过所有内容,但我无法获得任何其他信息。来自fb帐户。我只从facebook的策略中获取displayName和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' } }
答案 0 :(得分:1)
更改此
router.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
到此
router.get('/auth/facebook', passport.authenticate('facebook', { scope : ['email'] }));
并改变这一点:
profileFeilds
对此:
profileFields