Skip to content

Instantly share code, notes, and snippets.

@miki2826
Created July 24, 2016 14:47
Show Gist options
  • Save miki2826/66d64f6d040c7093da82ac56d9c16b05 to your computer and use it in GitHub Desktop.
Save miki2826/66d64f6d040c7093da82ac56d9c16b05 to your computer and use it in GitHub Desktop.
passport.use(new FacebookStrategy({
clientID: FACEBOOK_APP_ID,
clientSecret: FACEBOOK_APP_SECRET,
callbackURL: "http://localhost:3000/auth/facebook/callback"
},
function(accessToken, refreshToken, profile, cb) {
User.findOrCreate({ facebookId: profile.id }, function (err, user) {
return cb(err, user);
});
}
));
app.get('/auth/facebook',
passport.authenticate('facebook'));
app.get('/auth/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment