Configure GitHub login for Discourse

:bookmark: This guide explains how to set up GitHub as a login option for your Discourse forum by configuring OAuth credentials.

:person_raising_hand: Required user level: Administrator

Overview

GitHub login integration allows users to sign in to your Discourse site using their GitHub accounts. This provides a convenient authentication option, especially useful for developer-focused communities.

Setting up GitHub OAuth

  1. Visit GitHub’s developer settings at https://github.com/settings/developers

  2. In the left menu, locate and click on OAuth Apps

  3. Click New OAuth App

  4. Fill in the required fields:

    • Application name: Enter your site’s name
    • Homepage URL: Your site’s main URL (e.g., https://discourse.example.com)
    • Application description (optional): Briefly describe your site
    • Authorization callback URL: Use your site’s domain with the path /auth/github/callback
      (e.g., https://discourse.example.com/auth/github/callback)

  1. Click Register application

Configuring Discourse settings

  1. After registration, GitHub will provide you with two important credentials:

    • Client ID
    • Client Secret
  2. In your Discourse admin settings, configure the following:

    • Set github_client_id to your Client ID
    • Set github_client_secret to your Client Secret
    • Enable the enable github logins setting

Testing the integration

  1. Sign out of your Discourse site
  2. On the login page, you should now see a “with GitHub” login option
  3. Test the login flow to ensure it works as expected

Best practices

  • Keep your Client Secret secure and never share it publicly
  • Regularly review your GitHub OAuth app settings
  • Consider enabling additional security features in GitHub’s OAuth app settings

Common issues and solutions

  • If login fails, verify that your callback URL exactly matches what’s configured in GitHub
  • Ensure your site’s SSL certificate is valid, as GitHub requires HTTPS
  • Check that both client ID and secret are correctly entered in Discourse settings

Additional resources

Last edited by @jessii 2024-12-11T20:15:33Z

Check documentPerform check on document:
45 Likes