0
votes

I am getting the following error while trying to integrate linkedin login via passport linkedin:

Error: Failed to find request token in session at Strategy.OAuthStrategy.authenticate (C:\jobninja\facebookauth\node_modules\passport-linkedin\node_modules\passport-oauth1\lib\strategy.js:142:54) at Strategy.authenticate (C:\jobninja\facebookauth\node_modules\passport-linkedin\lib\strategy.js:118:40) at attempt (C:\jobninja\facebookauth\node_modules\passport\lib\middleware\authenticate.js:348:16) at authenticate (C:\jobninja\facebookauth\node_modules\passport\lib\middleware\authenticate.js:349:7) at Layer.handle [as handle_request] (C:\jobninja\facebookauth\node_modules\express\lib\router\layer.js:95:5) at next (C:\jobninja\facebookauth\node_modules\express\lib\router\route.js:131:13) at Route.dispatch (C:\jobninja\facebookauth\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\jobninja\facebookauth\node_modules\express\lib\router\layer.js:95:5) at C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:277:22 at Function.process_params (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:330:12) at next (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:271:10) at C:\jobninja\facebookauth\node_modules\connect-flash\lib\flash.js:21:5 at Layer.handle [as handle_request] (C:\jobninja\facebookauth\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:312:13) at C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:280:7 at Function.process_params (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:330:12).

Here is my code

passport.use(new LinkedInStrategy({

        consumerKey     : configAuth.linkedinAuth.clientID,
        consumerSecret  : configAuth.linkedinAuth.clientSecret,
        callbackURL     : configAuth.linkedinAuth.callbackURL,

    },
    function(token, refreshToken, profile, done) {

        // make the code asynchronous
        // User.findOne won't fire until we have all our data back from Linkedin
        process.nextTick(function() {

            // try to find the user based on their linkedin id
            User.findOne({ 'linkedin.id' : profile.id }, function(err, user) {
                if (err)
                    return done(err);

                if (user) {

                    // if a user is found, log them in
                    return done(null, user);
                } else {
                    // if the user isnt in our database, create a new user
                    var newUser          = new User();

                    // set all of the relevant information
                    newUser.linkedin.id    = profile.id;
                    newUser.linkedin.token = token;
                    newUser.linkedin.name  = profile.displayName;
                    newUser.linkedin.email = profile.emails[0].value; // pull the first email

                    // save the user
                    newUser.save(function(err) {
                        if (err)
                            throw err;
                        return done(null, newUser);
                    });
                }
            });
        });

    }));

Can anyone figure out the error and help?

1

1 Answers

0
votes

Does your callback url is the same as the initiaiting host url?