This guide explains how to set up GitHub as a login option for your Discourse forum by configuring OAuth credentials.
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
-
Visit GitHub’s developer settings at
https://github.com/settings/developers
-
In the left menu, locate and click on OAuth Apps
-
Click New OAuth App
-
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
)
- Click Register application
Configuring Discourse settings
-
After registration, GitHub will provide you with two important credentials:
- Client ID
- Client Secret
-
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
- Set
Testing the integration
- Sign out of your Discourse site
- On the login page, you should now see a “with GitHub” login option
- 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
- Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)
- Building OAuth apps - GitHub Docs
Last edited by @jessii 2024-12-11T20:15:33Z
Check document
Perform check on document: