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.
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.
This is a very late answer, but I just figured another reason this can happen. When the guys who made express-session said that MemoryStore is not meant for production, they really meant it.
If you're using clustering, (pm2 or forever or running on Heroku), then memory based cookie storages have their own set of problems. You'll often loose cookies or corrupt them (because there are two or more separate processes on server side, not sharing common memory).
If you want to run your Node app with clusters, you need to use Redis or some DB-backed cookie storage
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With