Configure Discord Login for Discourse

Discourse supports authentication via Discord. Once enabled and configured, login with Discord will appear alongside the other login methods for your forum:

Configuration

To get started, head over to Discord developer portal and create a new application. Choose a name, icon and description of your choice. These will be shown to users during the login flow.

Next, visit the OAuth2 tab on the left.

Copy the Client ID and Client Secret from this screen (you may need to click on “Reset Secret” if the secret key isn’t displayed in order to have one), and enter them into your Discourse settings under discord_client_id and discord_client_secret.

Under Redirects, enter your Discourse site URL (including https://), followed by /auth/discord/callback (No trailing slash!). Make sure you hit Save Changes before closing the window.

Don’t worry about using the ‘OAuth2 URL Generator’ - Discourse will handle that automatically.

Finally, go back to your Discourse site and enable the enable_discord_logins site setting. You should now have a working Discord login button on your site :tada:

Restricting access by Guild

By default, any Discord user can log into your Discourse forum. To restrict access to specific guilds, you can use the discord_trusted_guilds site setting.

First of all, find out the numeric ID for your Discord guild. The easiest way is to login to your guild and open a random channel. Check the URL in your browser, and copy the first number you see in it. The URL format is https://discordapp.com/channels/{guild}/{channel}. For example, given a URL as https://discordapp.com/channels/123/456, your guild ID would be 123.

Once you have the guild ID, add it to the discord_trusted_guilds setting in your Discourse site settings. You can add as many guilds to this list as you like. Now, users in the trusted guilds will be logged straight into your site. Anyone else will be shown this message when they try and get in. You can modify the message from your admin panel by searching for discord.not_in_allowed_guild under CustomizeText.

If you are relying on this guild restriction for security, make sure to disable all other Discourse login methods.

What next?
Now that your users can login with Discord, how about setting up the chat-integration plugin as well? That will push important topics from Discourse straight into your Discord channels. For more information, check out the chat-integration setup information.


Last Reviewed by @SaraDev on 2022-05-25T23:00:00Z

Last edited by @JammyDodger 2024-05-26T07:24:11Z

Check documentPerform check on document:
30 Likes