Discord Authentication
Follow these steps to enable "Sign in with Discord" on your Spokes server using the built-in Casdoor identity provider.
1. Get Discord Credentials
Section titled “1. Get Discord Credentials”- Go to the Discord Developer Portal and click New Application.
- Name your app (e.g., "Spokes Login") and click Create.
- Go to the OAuth2 tab in the left sidebar.
- Under Redirects, click Add Redirect and enter your exact Spokes callback URL:
https://<your-spokes-domain>/callback - Copy your Client ID.
- Click Reset Secret and copy your Client Secret.
2. Add the Discord Provider in Casdoor
Section titled “2. Add the Discord Provider in Casdoor”- Log into your Spokes admin account.
- Navigate to the Members & Groups (
/organization) page. - Click the Open Casdoor button in the top right corner to open the Casdoor dashboard.
- Go to Identity -> Providers -> Add in the top navigation bar.
- Configure the following fields:
- Name:
provider_discord - Category:
OAuth - Type:
Discord - Client ID: (Paste your Client ID from Step 1)
- Client Secret: (Paste your Client Secret from Step 1)
- Name:
- Click Save & Exit.
3. Enable Discord for the Spokes App
Section titled “3. Enable Discord for the Spokes App”- Go to Identity -> Applications in Casdoor and edit the
spokesapplication. - Under the Providers section, click Add and select
provider_discordfrom the dropdown list. - Click Save & Exit at the bottom of the page.
4. Configure Registration Rules
Section titled “4. Configure Registration Rules”Depending on how open or private you want your server to be, here are the three common ways to control who can register with Discord:
Option 1: Open to Anyone
Section titled “Option 1: Open to Anyone”Anyone with a Discord account can sign in and create an account.
- While editing the
spokesapplication in Casdoor, scroll to the Signup items table. - Find the row for Invitation code and uncheck the Required box (and optionally uncheck Visible).
- Make sure Enable signup is toggled ON.
- Click Save & Exit.
Option 2: Restricted by Email Address
Section titled “Option 2: Restricted by Email Address”Only specific Discord email addresses or domains are allowed to register.
- Go to Identity -> Providers and edit
provider_discord. - In the Email regex field, enter a regular expression matching the emails you want to allow, then save the provider:
- Specific Domain:
.*@yourdomain\.com$ - Specific Email List:
^(friend1@gmail\.com|friend2@gmail\.com)$
- Specific Domain:
- Go back to Identity -> Applications, edit
spokes, and uncheck Required on the Invitation code row in the Signup items table. - Tip: If you want to force users to sign in exclusively with Discord and disable manual username/password signups, you can hide the Signup link in the Signin items table and uncheck Visible on the items in the Signup items table.
- Click Save & Exit.
Option 3: Invite-Only (Link to Existing Accounts)
Section titled “Option 3: Invite-Only (Link to Existing Accounts)”Only users who already have an account (or an invitation code) can sign in with Discord.
- In the
spokesapplication settings, keep Invitation code checked as Required in the Signup items table. This blocks strangers from creating new accounts. - Make sure Enable Email linking is toggled ON.
- Click Save & Exit. (When an existing user whose Casdoor account has the same email address clicks the Discord login button, Casdoor will match their email and link their Discord account automatically.)
Troubleshooting Quick-Fixes
Section titled “Troubleshooting Quick-Fixes”- "Invalid OAuth2 Redirect URI" (in Discord): The Redirect URL in the Discord Developer Portal does not exactly match
https://<your-spokes-domain>/callback. Check for typos, trailing slashes, orhttp://instead ofhttps://. - "Failed to load callback handler" (in Casdoor/Spokes): Your Discord Client Secret is incorrect. Reset the secret in the Discord Developer Portal and paste the new value into
provider_discordin Casdoor.
