Skip to content

createDiscordOAuthClient

createDiscordOAuthClient(opts): object

Defined in: oauth/oauth.ts:23

Discord OAuth2 for “sign in with Discord”: build the link a member follows, trade the code Discord sends back for a token, and read who they are and which accounts they have linked. Used to learn a member’s Discord id together with their GitHub account, which Discord has verified.

The token endpoints take a form body and the client’s own credentials, which createDiscordBotClient’s JSON + bot-token client cannot send, so this has its own small transport.

DiscordOAuthClientOptions

authorizeUrl: (input) => string

The page a member opens to approve the application. state must be unguessable and checked when Discord sends the member back (see signOAuthState). prompt: "none" skips the approval screen for a member who already approved.

"consent" | "none"

readonly DiscordOAuthScope[]

string

string

connections: (accessToken) => Promise<DiscordConnection[]>

GET /users/@me/connections as the member (needs connections).

string

Promise<DiscordConnection[]>

exchangeCode: (code) => Promise<DiscordOAuthToken>

POST /oauth2/token — trades the one-use code from the redirect for a token.

string

Promise<DiscordOAuthToken>

refresh: (refreshToken) => Promise<DiscordOAuthToken>

POST /oauth2/token — a fresh token from a refresh_token.

string

Promise<DiscordOAuthToken>

revoke: (token) => Promise<void>

POST /oauth2/token/revoke — discards a token once it has been used; nothing needs to keep it.

string

Promise<void>

user: (accessToken) => Promise<DiscordOAuthUser>

GET /users/@me as the member (needs identify).

string

Promise<DiscordOAuthUser>