Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: failed to find request token in session #6

Open
realdope opened this issue Aug 26, 2013 · 7 comments
Open

Error: failed to find request token in session #6

realdope opened this issue Aug 26, 2013 · 7 comments

Comments

@realdope
Copy link

Hi, I have the following code:

  $.passport.use(new $.passport_local.Strategy({
    usernameField: "email"
  }, function(email, password, done) {
    $.auth.authenticate(email, password).then(function(user) {
      done(null, user);
    }).done();
  }));

  console.log("cALLBACK", app.get("frontend_url") + "/auth/linkedin/callback");

  $.passport.use(new $.passport_linkedin.Strategy({
    consumerKey: app.get("linkedin_apikey"),
    consumerSecret: app.get("linkedin_secret"),
    callbackURL: app.get("frontend_url") + "/auth/linkedin/callback"
  }, function(access_token, token_secret, profile, done) {
    $.auth.linkedin(access_token, token_secret, profile).then(function(user) {
      done(null, user);
    }).done();
  }));

I have passport-local and passport-linkedin. Both are working in local development environments. However, passport_linkedin doesn't work in production (nodejitsu). I'm getting

[08/26 11:20:26 EDT][err] Error: failed to find request token in session
[08/26 11:20:26 EDT][err]     at Strategy.OAuthStrategy.authenticate (/opt/run/snapshot/package/node_modules/passport-linkedin/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:124:54)
[08/26 11:20:26 EDT][err]     at Strategy.authenticate (/opt/run/snapshot/package/node_modules/passport-linkedin/lib/passport-linkedin/strategy.js:118:40)
[08/26 11:20:26 EDT][err]     at attempt (/opt/run/snapshot/package/node_modules/passport/lib/passport/middleware/authenticate.js:243:16)
[08/26 11:20:26 EDT][err]     at Passport.authenticate (/opt/run/snapshot/package/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
[08/26 11:20:26 EDT][err]     at callbacks (/opt/run/snapshot/package/node_modules/express/lib/router/index.js:161:37)
[08/26 11:20:26 EDT][err]     at param (/opt/run/snapshot/package/node_modules/express/lib/router/index.js:135:11)
[08/26 11:20:26 EDT][err]     at pass (/opt/run/snapshot/package/node_modules/express/lib/router/index.js:142:5)
[08/26 11:20:26 EDT][err]     at Router._dispatch (/opt/run/snapshot/package/node_modules/express/lib/router/index.js:170:5)
[08/26 11:20:26 EDT][err]     at Object.router (/opt/run/snapshot/package/node_modules/express/lib/router/index.js:33:10)
[08/26 11:20:26 EDT][err]     at next (/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/proto.js:190:15)

I've checked the domain name and subdomains, and found no discrepancy there between /auth/linkedin and /auth/linkedin/callback. I don't know what else could contribute to this error.

@JonWatkins
Copy link

I've had the same issue as this. We are using express and session-mongoose. Did you solve it?

@cjroebuck
Copy link

I had the error for a short while too but the code comment below made sense, and after changing my callback url to be the same as the initiaiting host url, it now works fine.

// Bail if the session does not contain the request token and corresponding
// secret.  If this happens, it is most likely caused by initiating OAuth
// from a different host than that of the callback endpoint (for example:
// initiating from 127.0.0.1 but handling callbacks at localhost).
if (!req.session[self._key]) { return self.error(new Error('failed to find request token in session')); }

@yackx
Copy link

yackx commented Dec 6, 2013

Thanks for the pointer @cjroebuck. Changing localhost to 127.0.0.1 solves it.

@AlmogBaku
Copy link

the solution @cjroebuck helps me too (the callback had www).
How can we fix it for every domain.

@gauravbansal74
Copy link

I am also getting same issue. please help +1

@askucher
Copy link

+1

1 similar comment
@bephrem1
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants