Req.user Undefined After Twitter Authentication Using Express Sever, Passport.js
There are many questions relating to getting a req.user undefined after social authentication, but I found none which could help me. I have been able to successfully use the examp
Solution 1:
The problem was in how my twitter_callback route was specified.
If I change the callback to this:
this.twitter_callback = app.get('/auth/twitter/return',
passport.authenticate('twitter', { failureRedirect: 'http://127.0.0.1:3000/signin' }),
function(req, res) {
console.log(req.user)
res.redirect('http://127.0.0.1:3000/search');
})
everything works fine. I think this has something to do with the middleware not being applied correctly the initial way I wrote it. Not exactly sure how I would rewrite it to export it, without using app.get in the twitter_callback though
Post a Comment for "Req.user Undefined After Twitter Authentication Using Express Sever, Passport.js"