メインコンテンツにスキップ

Add GitHub as an OAuth provider

This guide explains how to let users sign in to Casdoor with their GitHub account. The provider supports the web application flow and the device flow of GitHub.


Learning outcomes​

  • Register a GitHub App for Casdoor.
  • Add GitHub as an OAuth provider in Casdoor.

What you need​

  • A GitHub account
  • Administrator access to the Casdoor admin console

Register a GitHub App​

Use a GitHub App, not a legacy OAuth App. A GitHub App accepts several callback URLs, so one app can serve test and production. See Migrating OAuth Apps to GitHub Apps.

  1. Open New GitHub App in the developer settings of GitHub.

  2. Fill in GitHub App name, Homepage URL, and Description.

  3. Set Callback URL to the callback URL of Casdoor: https://<your-casdoor-host>/callback. This is the URL of Casdoor, not of your own application. See Redirect URL and callback URL.

    GitHub App registration form

  4. Create the app.

  5. In the settings of the app, generate a client secret, and copy the Client ID and the client secret.

    Client ID and client secret of the GitHub App

Add the provider in Casdoor​

  1. In the Casdoor admin console, go to Identity > Providers and add a provider.

  2. Set Category to OAuth and Type to GitHub.

  3. Enter the Client ID and the Client secret of the GitHub App.

    GitHub provider in Casdoor

  4. Save the provider.

GitHub App settings

Next steps​

Add the provider to an application. See Add providers to an application.

See also​