Skip to content

GitHub Integration: Initial Set up

Cheng Geng edited this page Jun 15, 2021 · 1 revision

Overview

In order for GitHub integration to function, the appropriate environment variables must be set.

This will allow the user to log-in to GitHub through the website, authenticating the website through the GitHub API.

OAuth Workflow

SourceAcademy makes use of the OAuth workflow for authenticating a log-in. The following steps are taken when the user attempts to log-in through SourceAcademy.

  1. SourceAcademy opens a pop-up directed to GitHub client of our application.
  2. The GitHub client redirects back to the GitHub callback page of SourceAcademy with an access code.
  3. The GitHub callback page sends the access code to our OAuth proxy.
  4. The OAuth proxy then exchanges the access code with GitHub in order to get an auth token.
  5. The auth token is then sent back to our callback page.
  6. With the auth token, we are able to complete the log-in.

Set-up

  1. Open the .env file
  2. Set REACT_APP_GITHUB_CLIENT_ID to the client ID.
  3. If you are unsure of the client ID, please navigate to Settings > Developer Settings for the SourceAcademy organization. Settings Developer Settings

There you should be able to find the OAuth apps. If you are deploying locally for testing, use Localhost client ID. If you are deploying for public use, use the GitHub Pages client ID. OAuth apps

  1. Set REACT_APP_GITHUB_OAUTH_PROXY_URL to https://api2.sourceacademy.nus.edu.sg/github_oauth.