Hey guys/gals, I'm trying to figure out how to create a twitter login for my app using passport.js and I think I've sort of got it working, but had a question or two that maybe you can help me out with.Below is the code that I need help understanding. When twitter redirects to my site, it doesn't console log out my 'Hello!' or the profile information that I'm needing. Can you think of a reason for that? What am I missing?Also the User.findOrCreate I'm assuming is trying to create a user for my database, which is why I commented that out currently, is that correct?passport.use(new TwitterStrategy({ consumerKey: process.env.CONSUMER_KEY, consumerSecret: process.env.CONSUMER_SECRET, callbackURL: "http://localhost:4200/home" }, function(token, tokenSecret, profile, done) { console.log('HELLO!') console.log(profile); // User.findOrCreate(..., function(err, user) { // if (err) { return done(err); } // done(null, user); // }); } )); Here is the routerouter.get('/auth/twitter', passport.authenticate('twitter')); And the callback:router.get('/auth/twitter/callback', passport.authenticate('twitter', { successRedirect: '/', failureRedirect: '/login' })); Thanks for any help!
Submitted January 21, 2020 at 01:22AM by OogieBoogie1
No comments:
Post a Comment