Tuesday, 21 January 2020

What am I doing wrong? Passport js

I cannot seem to get passport twitter login/auth to work I'd just like to console log out the profile but it never seems to work. Any help would be appreciated.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(profile); return done(null, profile); // User.findOrCreate(..., function(err, user) { // if (err) { return done(err); } // done(null, user); // }); } )); passport.serializeUser(function(user, callback){ callback(null, user); }) passport.deserializeUser(function(obj, callback){ callback(null, obj); }) // Redirect the user to Twitter for authentication. When complete, Twitter // will redirect the user back to the application at // /auth/twitter/callback router.get('/auth/twitter', passport.authenticate('twitter')); // Twitter will redirect the user to this URL after approval. Finish the // authentication process by attempting to obtain an access token. If // access was granted, the user will be logged in. Otherwise, // authentication has failed. router.get('/home', passport.authenticate('twitter', {failureRedirect: '/login' }), function(req, res){ res.redirect('/') });

Submitted January 22, 2020 at 02:38AM by OogieBoogie1

No comments:

Post a Comment