1

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' }) ); 

1 Answer 1

1

if both urls are on the same domain, port and protocol, you can speciy a URL that is above the ones you want to use, for example:

if your pages are on https://example.com/oauth/authorize and https://example.com/oauth/authenticate

you can set https://example.com/oauthas callback URL in github and throw in the redirect_uri parameter in the request to github.

more here: https://developer.github.com/v3/oauth/#redirect-urls

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.