Discord
Discord is an OAuth 2.0 preset shipped from v0.5 of authn.sh. Discord doesn’t expose OIDC discovery, so the preset is wired as plain OAuth 2.0 with hard-coded endpoints.
Default scopes
Section titled “Default scopes”| Scope | Returns |
|---|---|
identify | Discord id, username, discriminator, avatar. |
email | Verified primary email address. |
Add more scopes per row if you need guild membership / friends list / etc. — they go on the scopes[] field of the OauthProvider row.
Register an application on Discord
Section titled “Register an application on Discord”- Open the Discord Developer Portal → Applications and click New Application.
- Name the app (this is what users see at the consent screen) and confirm.
- Open OAuth2 → General.
- Under Redirects, paste the
redirect_urifrom your authn.shOauthProviderrow — the canonical format ishttps://<env_slug>.authn.sh/v1/oauth-callback/discord(or the equivalent under your self-hosted apex). Save. - Copy Client ID and click Reset Secret to generate a fresh Client Secret. Copy it.
Configure the provider in authn.sh
Section titled “Configure the provider in authn.sh”Click through Dashboard → Configure → Authentication → Social providers → Add provider → Discord and paste the credentials. Or POST via BAPI:
POST /v1/oauth-providersAuthorization: Bearer sk_live_…Content-Type: application/json
{ "provider_kind": "preset", "provider_key": "discord", "name": "Discord", "client_id": "1234567890123456789", "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}attribute_mapping
Section titled “attribute_mapping”The preset ships with sensible defaults — no override needed for the common case:
| authn.sh field | Discord claim |
|---|---|
email_address | email |
first_name | username |
provider_user_id | id |
profile_image_url | avatar (the SDK rewrites it to the full CDN URL) |
If you’d rather use the Discord global display name as first_name, override attribute_mapping:
{ "attribute_mapping": { "email_address": "email", "first_name": "global_name", "provider_user_id": "id" }}- Discord requires the user’s primary email to be verified before it surfaces it on the userinfo response. authn.sh trusts this — accounts created via Discord land with
email_address.verified: true. - Discord’s userinfo response is paginated only for friends / guilds. The basic
identify+emailpayload comes back in a single call.