just yesterday on Heroku I started to have this error on twitter login in express
Error: failed to find request token in session
at Strategy.<anonymous> (/app/node_modules/passport-twitter/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:120:54)
at Strategy.authenticate (/app/node_modules/passport-twitter/lib/passport-twitter/strategy.js:82:40)
at Passport.authenticate (/app/node_modules/passport/lib/passport/middleware/authenticate.js:153:14)
at callbacks (/app/node_modules/express/lib/router/index.js:272:11)
at param (/app/node_modules/express/lib/router/index.js:246:11)
at pass (/app/node_modules/express/lib/router/index.js:253:5)
at Router._dispatch (/app/node_modules/express/lib/router/index.js:280:4)
at Object.handle (/app/node_modules/express/lib/router/index.js:45:10)
at Context.next (/app/node_modules/express/node_modules/connect/lib/http.js:204:15)
at Context.<anonymous> (/app/node_modules/passport/lib/passport/context/http/actions.js:64:8)
any suggestion?
YUHU I solved. the problem was that some times my website had www and sometimes not, so there were problems with sessions, apparently.
This is totally random, and I'm a Node newb... so apply salt liberally.
I was seeing this error and a very similar stack trace tonight, actually. It turned out that I had just changed my auth callback route to look like this:
app.use('/auth/twitter/callback', twitterCallback);
See how I used use
there instead of get
? Once I changed it back, I stopped getting this error.
My stack trace looked a bit different, though:
DEBUG: Error: failed to find request token in session
at Strategy. (/Users/drhayes/src/incursion/node_modules/passport-twitter/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:122:54)
at Strategy.authenticate (/Users/drhayes/src/incursion/node_modules/passport-twitter/lib/passport-twitter/strategy.js:82:40)
at Passport.authenticate (/Users/drhayes/src/incursion/node_modules/passport/lib/passport/middleware/authenticate.js:153:14)
at Object.handle (native)
at next (/Users/drhayes/src/incursion/node_modules/express/node_modules/connect/lib/http.js:204:15)
at /Users/drhayes/src/incursion/node_modules/passport/lib/passport/middleware/authenticate.js:99:9
at /Users/drhayes/src/incursion/node_modules/passport/lib/passport/http/request.js:46:7
at pass (/Users/drhayes/src/incursion/node_modules/passport/lib/passport/index.js:229:30)
at /Users/drhayes/src/incursion/node_modules/passport/lib/passport/index.js:237:36
at /Users/drhayes/src/incursion/routes/auth.coffee:42:14
Has your source changed recently? Is there a revision bump in your deployed slug?
I also encountered this error using Node.js, Express & Passport, although my fix was different than those described above.
I had copied and pasted the following code from the 'express-session' documentation...
app.use(session({ secret: 'keyboard cat', key: 'sid', cookie: { secure: true }}))
That secure: true bit instructs express-session to use 'https', which I don't have setup in my development environment. Once I removed it, the error went away.
In Twitters app settings, ensure the following fields have these values:
Website : http://127.0.0.1:3000
Callback URL : http://127.0.0.1:3000/auth/twitter/callback'
**I am working with port number 3000. You could change that to whatever port you are working with.
Now, navigate to http://127.0.0.1:3000 in your browser. This should solve your problem.