Reputation: 5
I have tried everything but I am not able to get any other info. from fb account. I am only getting displayName and id from my facebook strategy :
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);
}));
The get part:
router.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
router.get('/auth/facebook/callback',
passport.authenticate('facebook', {
successRedirect : '/',
failureRedirect : '/blogs',
//scope:['email']
}));
Output:
{ 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' } }
Upvotes: 0
Views: 962
Reputation: 569
Change this
router.get('/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
To this
router.get('/auth/facebook', passport.authenticate('facebook', { scope : ['email'] }));
And change this:
profileFeilds
To this:
profileFields
Upvotes: 2