Open dawningfuture opened 8 years ago
fcebook is shit. maybe this time the lib is shit, but as displayed, this should work, noob :) console.log(profile._json.friends);
For sure I resorted to that, just figured I could improve the lib with a PR (in progress)
I face a similar issue, but not with "friends" with "work" and "education" fields. They are present in raw and _json, but not part of profile object itself.
I am trying to get the friend list for users that use my app. Here's my route:
app.get('/login/facebook', passport.authenticate('facebook-login', { 'scope': ['email', 'public_profile', 'user_friends'] }))
and my passport-facebook config object:
var facebookLoginStrategy = new FacebookStrategy({ clientID: process.env.FACEBOOK_APP_ID, clientSecret: process.env.FACEBOOK_APP_SECRET, callbackURL: process.env.API_URL + "/login/facebook-callback", passReqToCallback: true, profileFields: ['email', 'friends', 'displayName', 'picture.type(large)'] }, function(req, accessToken, refreshToken, profile, done) { console.log(profile) ... })
Here's what's logged:
{ id: 'xxx', username: undefined, displayName: 'xxx', name: { familyName: undefined, givenName: undefined, middleName: undefined }, gender: undefined, profileUrl: undefined, emails: [ { value: 'xxx' } ], photos: [ { value: 'xxx' } ], provider: 'facebook', _raw: '...', _json: { email: '...', friends: { data: [Object], paging: [Object], summary: [Object] }, name: '...', picture: { data: [Object] }, id: 'xxx' } }
As you can see, the friends object is returned in the _json object, but not in the profile object itself. Is this a bug with passport-facebook, or with the Facebook API itself? Thanks in advance for any help.