node.js - Passport strategy for authenticating with LinkedIn using the OAuth 1.0a API return undefined email on save User -


i beginner in node.js development , trying build application based on express framework. implemented passport-local passport-facebook , passport-linkedin users sign , log in application linking multiple social account single user account in mongodb (from tutorial).

my problem undefined e-mail field when using passport-linkedin if can firstname , lastname correctly authenticated user.

passport.js

passport.use(new linkedinstrategy({ consumerkey     : configauth.linkedinauth.consumerkey, consumersecret  : configauth.linkedinauth.consumersecret, callbackurl     : configauth.linkedinauth.callbackurl, passreqtocallback : true // allows pass in req our route (lets check if user logged in or not) },   function(req, token, tokensecret, profile, done) {   // asynchronous   process.nexttick(function() {    // check if user logged in    if (!req.user) {     user.findone({ 'linkedin.id' : profile.id }, function(err, user) {     if (err)         return done(err);       if (user) {         // if there user id no token (user linked @ 1 point , removed)         if (!user.linkedin.token) {         [...]         } else {          // if there no user, create them          var newuser                  = new user();          newuser.linkedin.id          = profile.id;          newuser.linkedin.token       = token;          newuser.linkedin.firstname   = profile.name.givenname;          newuser.linkedin.lastname    = profile.name.familyname;          newuser.linkedin.email       = profile.emails;          newuser.save(function(err) {             if (err)                 return done(err);             return done(null, newuser);          });         }       });     } else {     // user exists , logged in, have link accounts     [...]   }  }); })); 

routes/accounts.js

// linkedin -------------------------------- // send linkedin authentication app.get('/auth/linkedin', passport.authenticate('linkedin', { scope: ['r_basicprofile', 'r_emailaddress'] }));  // handle callback after linkedin has authenticated user app.get('/auth/linkedin/callback',   passport.authenticate('linkedin', {     successredirect : '/profile', // redirect secure profile section     failureredirect : '/signup', // redirect signup page if there error     failureflash : true // allow flash messages })); 

i find firstname , lastname save user database looking @ passport-linkedin/lib/strategy.js, did same profile.emails bit still remains "undefined" after authenticating proprely user.

thank in advance help.

edit: linkedin developer faq

while have not announced official deprecation of oauth 1.0a in conjunction linkedin's apis, no longer actively encourage or support use.

existing applications built oauth 1.0a continue functional until such time officially announce sunset.

using or transitioning oauth 2.0 encouraged applications.

had same issue while , got working. have tried oauth2? if have implemented passport-linkedin should minor changes passport.js file. oauth 1.0 deprecated linkedin, hence why may causes issues retrieve information. guess you're facing same situation. try , should go!


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -