Facebook-passport with JWT

The best solution I found for that problem would be to redirect to the expected page with a cookie which holds the JWT. Using res.json would only send a json response and would not redirect. That’s why the other suggested answer here would not solve the problem I encountered. So my solution would be: app.get(‘/auth/facebook/callback’, … Read more

Passport-Facebook authentication is not providing email for all Facebook accounts

Make sure these two things are in your code: passport.use(new FacebookStrategy({ clientID: ‘CLIENT_ID’, clientSecret: ‘CLIENT_SECRET’, callbackURL: “http://www.example.com/auth/facebook/callback” passReqToCallback : true, profileFields: [‘id’, ’emails’, ‘name’] //This }, and this: app.get(‘/connect/facebook’, passport.authorize(‘facebook’, { scope : [’email’] })); This gives you access to the following: profile.id profile.name.givenName profile.name.familyName profile.emails The last one being an array, so use profile.emails[0].value … Read more

passport.js with multiple authentication providers?

Passport’s middleware is built in a way that allows you to use multiple strategies in one passport.authenticate(…) call. However, it is defined with an OR order. This is, it will only fail if none of the strategies returned success. This is how you would use it: app.post(‘/login’, passport.authenticate([‘local’, ‘basic’, ‘passport-google-oauth’]), /* this is how */ … Read more