Configure Discord Login for Discourse

:bookmark: This guide explains how to set up and configure Discord as a login option for your Discourse forum, including how to restrict access to specific Discord guilds.

:person_raising_hand: Required user level: Administrator

Once configured, Discord will appear as a login option alongside other authentication methods on your forum:

Setting up Discord OAuth2

Creating a Discord application

  1. Visit the Discord developer portal
  2. Click “New Application”
  3. Enter a name, upload an icon, and add a description for your application
    • These details will be shown to users during the login process

Configuring OAuth2 settings

  1. Navigate to the “OAuth2” tab in the left sidebar

  1. Copy the “Client ID” and “Client Secret”
    • If the secret isn’t visible, click “Reset Secret” to generate a new one
  2. Add your redirect URL:
    • Format: https://your-discourse-site.com/auth/discord/callback
    • :warning: Do not include a trailing slash
  3. Click “Save Changes”

Enabling Discord login in Discourse

  1. In your Discourse admin settings, enter the Client ID in the discord_client_id setting
  2. Enter the Client Secret in the discord_secret setting
  3. Enable the enable_discord_logins setting

Restricting access to specific Discord guilds

You can limit Discord login to members of specific Discord guilds (servers).

Finding your guild ID

  1. Open Discord in your browser
  2. Navigate to any channel in your guild
  3. Look at the URL: https://discord.com/channels/{guild_id}/{channel_id}
  4. Copy the first number (guild_id) from the URL
    • Example: In https://discord.com/channels/123/456, the guild ID is 123

Configuring guild restrictions

  1. In your Discourse admin settings, locate the discord_trusted_guilds setting
  2. Add your guild ID(s)
    • You can add multiple guild IDs if needed

When guild restriction is enabled:

  • Members of trusted guilds will log in normally
  • Other users will see an error message
  • You can customize this message under Customize → Text, search for discord.not_in_allowed_guild

:warning: If you’re using guild restrictions for security, disable all other login methods in your Discourse settings.

Next steps

Consider setting up the chat-integration plugin to push important Discourse topics to your Discord channels.

Last edited by @jessii 2024-12-11T19:59:00Z

Check documentPerform check on document:
34개의 좋아요

게시물이 새 주제로 분리되었습니다: Add more scopes to discord login

요즘 디스코드 채널 ID가 discord.com으로 시작하는 거 아닌가요? 웹에서 디스코드를 쓸 때, 지난 몇 년간 항상 discord.com/channels/[guild_id]/[channel_id] 형식이었거든요.

이 가이드가 상당히 오래된 것 같습니다. Discourse 관리자 화면에서는 다음을 지정할 수 있습니다:

  • Discord 로그인 활성화
  • Discord 클라이언트 ID
  • Discord 시크릿
  • Discord 신뢰 길드 (선택 사항)

한편, Discord 개발자 화면에서는 다음 항목이 있습니다:

  • 이름
  • 설명 (선택 사항)
  • 애플리케이션 ID
  • 공개 키
  • 인터랙션 엔드포인트 URL (선택 사항)
  • 연결된 역할 검증 URL (선택 사항)

다음과 같은 가정을 한다면

  • Discord 클라이언트 ID가 애플리케이션 ID와 같고,
  • Discord 시크릿이 공개 키와 같으며,
  • 선택 사항 항목은 비워 둔다고 하면,

인증 시도에 Discord 오류가 발생합니다:

인터랙션 엔드포인트 URL을
https://forum.example.com/auth/discord/callback으로 설정해 보면,
Discord 개발자 화면에서 다음과 같은 오류가 표시됩니다:

Validation errors:
    interactions_endpoint_url: The specified interactions endpoint url could not be verified.

이것을 설정하는 올바른 절차는 무엇인가요?

안녕하세요,

같은 오류 "Invalid OAuth2 redirect_uri"가 발생합니다.

통합에 성공하신 분이 계신가요?

방금 테스트해 봤는데, OP의 단계대로 하면 저에게도 잘 작동했습니다. 지시대로 사이트 URL을 추가했습니다:

https://test.mydomain.com/auth/discord/callback

오류 없이 정상적으로 받아들여졌습니다. Oauth2 > Redirects 섹션에 이 주소를 추가해야 합니다.

5개의 좋아요

정말 감사합니다, pmusaraj.

저는 이 페이지의 튜토리얼을 읽고 discourse 문서는 읽지 않았었습니다.

다음에는 같은 실수를 하지 않겠습니다. 불편을 드려 죄송합니다. :sweat_smile:

3개의 좋아요