Authenticating users with a 3rd party OAuth service (github)


#1

Hello,

We are in the process of migrating our website to the COS. In order to complete the migration, we need to get our sign up/sign in/forgot password links working properly.

Our signup/signin button on our current website uses custom javascript to direct users to their Github account to authorize our product to access their account, it then sets cookies so that once they have logged in they stay logged in until the cookies expire.

We need to replicate this behavior on the COS and need help figuring out how to do it properly. Ideally we would like a big CTA right in the hero banner and also on various other locations throughout the website.

Can anyone help to point us in the right direction so that we can figure out how to:

  • Use custom JS in a CTA action to direct users to github to authorize our product for access
  • Implement a callback URL within COS that github can post to with a query string (token)
  • Set cookies once a user has been authenticated

What I mean by that is explained by this flow:

  1. User clicks on “Sign in with Github” button on our COS site
  2. User is redirected to github to authorized us to access their GitHub account
  3. When they click authorize, GitHub fires a request to a URL on our COS site with a query string containing their token like: cosbeta.containership.io/user/auth?token=12345
  4. We then set a cookie on the user’s browser

I see I can have a COS URL mapping, but how can I implement a route on the COS that will accept a query string and fire some javascript?

I cannot seem to find information about how to accomplish this anywhere.

I see that this very forum has github signup. How can I get this same functionality?