drudge / passport-facebook-token

Passport strategy for authenticating with Facebook access tokens using the OAuth 2.0 API.
MIT License
390 stars 80 forks source link

facebook gender is empty for Sails framework? #66

Open ghost opened 7 years ago

ghost commented 7 years ago

console.log of profile gives :

     id: '336360503408940',
  displayName: 'Ray Slim',
 name: { familyName: 'Slim', givenName: 'Ray', middleName: '' },
 gender: '',
  emails: [ { value: '' } ],
 photos: [ { value: 'https://graph.facebook.com/v2.6/336360503408940/picture?type=large' } ],
 _raw: '{"id":"336360503408940","name":"Ray Slim","last_name":"Slim","first_name":"Ray"}',
 _json: 
  { id: '336360503408940',
   name: 'Ray ',
     last_name: 'Ray Slim',

As you can see, gender has no value. Why is that? Below is my token strategy, similar to a lot of them

var facebookLoginStrategy = new FacebookTokenStrategy({ clientID: '1512072982155691', clientSecret: '7b89b4bdfba3408b68efe9fd1c3a8164' }, function(accessToken, refreshToken, profile, done) {

User.findOrCreate({ id: profile.id}, function (err, user) {

console.log(profile)

return done(err, user);

});

});

ghost commented 7 years ago

It seems to be showing on everyone else's.. is it just a sails thing?

ghaiklor commented 7 years ago

@rslim087g could be that profile you got just doesn't have gender property.

ghost commented 7 years ago

I tried three profiles. If I do a facebook graph request on the client side it gives me gender for all of them.

ghost commented 7 years ago

Could it be a framework or library that I'm not using ?

ghost commented 7 years ago

only frameworks I'm using are app.use(bodyParser.json()); , and passport.use(facebookLoginStrategy) , do I need some other parser for things like gender??

ghost commented 7 years ago

figured it out, had to add this

clientID: '1512072982155691',
clientSecret: '7b89b4bdfba3408b68efe9fd1c3a8164',

------> profileFields: ['id', 'displayName', 'gender']

agalazis commented 7 years ago

relates to #68 @ghaiklor seems to be an outdated doc issue