jaredhanson / passport-fitbit

Fitbit authentication strategy for Passport and Node.js.
MIT License
33 stars 15 forks source link

Error: failed to find request token in session #1

Closed brianyang closed 11 years ago

brianyang commented 11 years ago

Hello Jared,

I really like passport and have used it for fb, twitter, google, and custom login on another project. i have a fitbit project i'm working on and i cant seem to get the login example to work. i replace the fitbit key and secret, login and get redirected and authorize; but then i get this error below. do you know why this isn't working?

Error: failed to find request token in session at Strategy.OAuthStrategy.authenticate (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/passport-fitbit/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:122:54) at attempt (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/passport/lib/passport/middleware/authenticate.js:243:16) at Passport.authenticate (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/passport/lib/passport/middleware/authenticate.js:244:7) at callbacks (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/express/lib/router/index.js:160:37) at param (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/express/lib/router/index.js:134:11) at pass (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/express/lib/router/index.js:141:5) at Router._dispatch (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/express/lib/router/index.js:169:5) at Object.router (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/express/lib/router/index.js:32:10) at Context.next (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Context.actions.pass (/Users/brian/Public/proto/passport-fitbit/examples/login/node_modules/passport/lib/passport/context/http/actions.js:77:8)

jaredhanson commented 11 years ago

This typically happens when when the redirect back to your app goes to a different domain (example.com to www.example.com) in which case the session isn't restored correctly because the cookie isn't sent.

Related discussion here: https://github.com/jaredhanson/passport-twitter/issues/12

tejas-kr commented 7 years ago

Hey if someone is still having the issue I have another solution...

add this code :

app.use(passport.session({ secret: 'Shhh.. This is a secret', cookie: { secure: true } })); just add cookie: { secure: true} and it will work just fine...

I too had this issue and above technique helped me solve this.