I want to be able to authenticate
(for signing up with GitHub) and authorize
(for linking GitHub account to an existing account) in separate routes for GitHub OAuth. I handle this with LinkedIn OAuth with two different routes, one that calls passport.authenticate()
and one that calls passport.authorize()
. GitHub only allows you to have one callback URL though.
I've found this post explaining a workaround, but do not know exactly how to implement the answer.
Below is my setup with Linkedin OAuth that works fine.
router.get('/auth/linkedin', passport.authenticate('linkedin'));
router.get('/auth/linkedin/callback', passport.authenticate('linkedin', {
failureRedirect : '/app/#/login'
}), function(req, res){
res.redirect('/app/#/profile');
});
router.get('/connect/linkedin',
passport.authorize('linkedin', {
failureRedirect: '/app/#/login' })
);
router.get('/connect/linkedin/callback',
passport.authorize('linkedin', {
successRedirect : '/app/#/profile',
failureRedirect : '/app/#/login'
})
);