passport-facebook in nodejs - profile fields

Viewed 8572

some of the profile fields i am trying to get from Facebook when logging in a user, are not going through.

I am using passportjs in node. this is the facebook strategy:

passport.use(new FacebookStrategy({
  clientID: FACEBOOK_APP_ID,
  clientSecret: FACEBOOK_APP_SECRET,
  callbackURL: FACEBOOK_CALLBACK_URL,
  profileFields: ['id', 'displayName', 'link', 'about_me', 'photos', 'email']
},
routes.handleLogin
));

being used with:

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

the result is that 'link', 'about_me' and 'email' are not getting pulled while the other fields are.

3 Answers

aturkelson is correct. about_me is not supported yet. As far as email it comes with the profile as long as you request it. I also have a console log to confirm I am not crazy.

//Passport facebook strategy
exports.passportInit= passport.use(new facebookStrategy({
clientID: process.env.FACEBOOK_APP_ID ,
clientSecret: process.env.FACEBOOK_SECRET_ID,
callbackURL: '/api/auth/facebook/callback',
profileFields: ['id', 'displayName', 'emails', 'photos']
},
function(accessToken, refreshToken, profile, done) {
console.log(profile);
 db.User.findOne({facebook_id: profile.id}, function(err, oldUser){
     if(oldUser){
         done(null,oldUser);
     }else{
         var newUser = new db.User({
             facebook_id : profile.id,
             facebook_photo : profile.photos[0].value,
             email : profile.emails[0].value,
             display_name : profile.displayName,
             // picture: profile.picture
         }).save(function(err,newUser){
             if(err) throw err;
             done(null, newUser);
         });
     }
 });
}
));
Related