passport-linkedin-oauth2 not returning email address

Posted by biborno on Stack Overflow See other posts from Stack Overflow or by biborno
Published on 2013-11-01T07:11:49Z Indexed on 2013/11/01 9:54 UTC
Read the original article Hit count: 488

Filed under:
|
|
|

here is my console.log(profile);

{ provider: 'linkedin',
  id: 'LJitOAshpU',
  displayName: 'Monist BD',
  name: { familyName: 'BD', givenName: 'Monist' },
  emails: [ { value: undefined } ],
  _raw: '{\n  "firstName": "Monist",\n  "formattedName": "Monist BD",\n  "id": "
LJitOAshpU",\n  "lastName": "BD"\n}',
  _json:
   { firstName: 'Monist',
     formattedName: 'Monist BD',
     id: 'LJitOAshpU',
     lastName: 'BD' } }

here is my routing code:

 app.get('/auth/linkedin',passport.authenticate('linkedin', { scope: ['r_emailaddress', 'r_basicprofile', 'rw_nus'],state: 'DCEEFWF45453sdffef424' }));

app.get('/auth/linkedin/callback',passport.authenticate('linkedin', { failureRedirect: '/' }),users.authCallback);

here is passport.js config:

 passport.use(new LinkedInStrategy({
    clientID: config.linkedIn.clientID,
    clientSecret: config.linkedIn.clientSecret,
    callbackURL: config.linkedIn.callbackURL,
    profileFields: ['id', 'first-name', 'last-name', 'email-address','public-profile-url'],
    passReqToCallback: true
  },
  function(req,token, refreshToken, profile, done) {

    console.log(profile);
}));

why i m getting undefined in email values? :( it worked when i used passport-linkedin

© Stack Overflow or respective owner

Related posts about node.js

Related posts about oauth-2.0