I am integrating passport
with sails
.
While google and facebook is working fine in my application I struggle with twitter authentication! When clicking on the 'login with twitter' button there is an error thrown wich says: Error: OAuthStrategy requires session support. Did you forget app.use(express.session(...))?
I read here that sessions are necessary for twitter authentication to work. I made sure my app has sessions activated!
I testet passport-twitter
with a simple express app (without sails) to make sure the module is working and my twitter credentials are intact.
I am assuming sails sessions are different to express sessions? Is sails changing the way sessions work? Any advice on how to solve this?
EDIT: Added some more info as requested in the comments:
Sails Version: 0.9.13
UserController.js:
...
twitter: function(res, req) {
passport.authenticate('twitter', {failureRedirect: '/login'}, function(err, user, info) {
return console.log(err, user, info);
})(req, res);
}
...
config/passport.js:
...
passport.use(new TwitterStrategy({
consumerKey: '**************',
consumerSecret: '********************',
callbackURL: "http://127.0.0.1:1337/auth/twitter/callback"
},
function(token, tokenSecret, profile, done){
process.nextTick(function() {
console.log(profile);
});
}
));
...
Did you try sails-generate-auth with sails 0.10? It makes life easier from my point of view: https://www.npmjs.org/package/sails-generate-auth
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