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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”authorizeUrl
Section titled “authorizeUrl”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.
Parameters
Section titled “Parameters”prompt?
Section titled “prompt?”"consent" | "none"
scopes?
Section titled “scopes?”readonly DiscordOAuthScope[]
string
Returns
Section titled “Returns”string
connections
Section titled “connections”connections: (
accessToken) =>Promise<DiscordConnection[]>
GET /users/@me/connections as the member (needs connections).
Parameters
Section titled “Parameters”accessToken
Section titled “accessToken”string
Returns
Section titled “Returns”Promise<DiscordConnection[]>
exchangeCode
Section titled “exchangeCode”exchangeCode: (
code) =>Promise<DiscordOAuthToken>
POST /oauth2/token — trades the one-use code from the redirect for a token.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<DiscordOAuthToken>
refresh
Section titled “refresh”refresh: (
refreshToken) =>Promise<DiscordOAuthToken>
POST /oauth2/token — a fresh token from a refresh_token.
Parameters
Section titled “Parameters”refreshToken
Section titled “refreshToken”string
Returns
Section titled “Returns”Promise<DiscordOAuthToken>
revoke
Section titled “revoke”revoke: (
token) =>Promise<void>
POST /oauth2/token/revoke — discards a token once it has been used; nothing needs to keep it.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
user: (
accessToken) =>Promise<DiscordOAuthUser>
GET /users/@me as the member (needs identify).
Parameters
Section titled “Parameters”accessToken
Section titled “accessToken”string
Returns
Section titled “Returns”Promise<DiscordOAuthUser>