Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

facebook gender is empty for Sails framework? #66

Open
ghost opened this issue Dec 15, 2016 · 7 comments
Open

facebook gender is empty for Sails framework? #66

ghost opened this issue Dec 15, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented Dec 15, 2016

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
Copy link
Author

ghost commented Dec 15, 2016

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

@ghaiklor
Copy link
Collaborator

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

@ghost
Copy link
Author

ghost commented Dec 15, 2016

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

@ghost
Copy link
Author

ghost commented Dec 15, 2016

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

@ghost
Copy link
Author

ghost commented Dec 15, 2016

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
Copy link
Author

ghost commented Dec 15, 2016

figured it out, had to add this

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

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

@agalazis
Copy link

agalazis commented Jul 22, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants