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.
- 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.”
- 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).
- 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_urisent in the authorization request must match a registered redirect. - 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. - Authorize at
https://discord.com/oauth2/authorize?response_type=code&client_id=...&scope=...&redirect_uri=...&state=.... Discord highly recommends (but does not require) thestateparameter for CSRF protection. - Exchange the returned
codeathttps://discord.com/api/oauth2/token. Authenticate the request with HTTP Basic (client ID as username, client secret as password) or by puttingclient_id/client_secretin the form body — and note the endpoint only acceptsapplication/x-www-form-urlencoded; JSON is rejected.
Operational notes (from docs.discord.com/developers/topics/oauth2):
- Access tokens expire (
expires_inis 604800 seconds — 7 days — in every documented example); refresh withgrant_type=refresh_tokenagainst the same token URL. - Revoking any token at
https://discord.com/api/oauth2/token/revokerevokes all active access and refresh tokens of that authorization. prompt=noneskips the consent screen for previously authorized scopes; passthrough scopes likebotandwebhook.incomingalways require re-approval.- Verify a live token with
GET /oauth2/@me(bearer auth) — it returns the granted scopes and expiry.
Connect it to Publicus
Section titled “Connect it to Publicus”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.