Skip to content
Docs

Creating a Discord OAuth 2.0 client

This guide is part of the Publicus connection catalog. Once you have the credentials, connect the service and Publicus stores them for you.

Distilled from Discord’s own documentation: OAuth2 and Getting Started. Retrieved 2026-07-03.

  1. Open the Discord Developer Portal applications page and click New Application; name it and accept the developer terms. Discord’s OAuth2 docs start here: “The first step in implementing OAuth2 is registering a developer application and retrieving your client ID and client secret.”
  2. On the app’s OAuth2 page, record the Client ID and generate/record the Client Secret (it is only shown when (re)generated — store it safely).
  3. Still on the OAuth2 page, add your Redirect URL exactly as shown on the connect form. Discord exchanges the code only against “whatever URL you registered when creating your application” — the redirect_uri sent in the authorization request must match a registered redirect.
  4. Choose the scopes the connection needs (see the per-capability scopes in this catalog entry). Scopes are space-separated (%20-encoded) in the authorization URL, e.g. scope=identify%20guilds.
  5. Authorize at https://discord.com/oauth2/authorize?response_type=code&client_id=...&scope=...&redirect_uri=...&state=.... Discord highly recommends (but does not require) the state parameter for CSRF protection.
  6. Exchange the returned code at https://discord.com/api/oauth2/token. Authenticate the request with HTTP Basic (client ID as username, client secret as password) or by putting client_id/client_secret in the form body — and note the endpoint only accepts application/x-www-form-urlencoded; JSON is rejected.

Operational notes (from docs.discord.com/developers/topics/oauth2):

  • Access tokens expire (expires_in is 604800 seconds — 7 days — in every documented example); refresh with grant_type=refresh_token against the same token URL.
  • Revoking any token at https://discord.com/api/oauth2/token/revoke revokes all active access and refresh tokens of that authorization.
  • prompt=none skips the consent screen for previously authorized scopes; passthrough scopes like bot and webhook.incoming always require re-approval.
  • Verify a live token with GET /oauth2/@me (bearer auth) — it returns the granted scopes and expiry.

Open Connections under Credentials, choose Discord, and pick Discord OAuth 2.0. Publicus asks for exactly the fields listed above and keeps them in your workspace’s secret storage.

See also: Discord in the catalog.

This guide is maintained by Publicus and published under CC BY 4.0.