Skip to content
Interfaceplugin-oauthv0.1.0

OAuthClientOptions

What OAuthClient needs to talk to Discord and to keep each user's tokens.

interface OAuthClientOptions<
    TScopes extends OAuthScope = never,
    TExtra extends OAuthScope = never
>

baseUrl

The public address of your server. It can have a path, like https://example.com/bot. The login routes are under it.

baseUrl: string | URL;

clientId

The application's id.

clientId: string;

clientSecret

The client secret from the application's OAuth2 page. The client also derives the token encryption key from it. After you rotate it, every user has to log in again.

clientSecret: string;

extraScopes

Scopes that only some of your features need. A login requests one only when its link lists it, and the typed calls for it resolve to undefined for a user who hasn't granted it yet.

extraScopes?: readonly TExtra[] | undefined

keepOpen

Only for Cloudflare Workers, where you pass waitUntil from cloudflare:workers. The client hands it every change to a user's tokens. Workers freezes a change once its request ends, and that user's later calls would wait on it forever. The OAuth plugin sets this for you.

keepOpen?: ((work: Promise<void>) => void) | undefined

rest

A @discordjs/rest client. Every call waits in its rate limit queue. Only joinGuild() sends its bot token.

rest: REST;

routes

Set these when your site already has its own paths for a Discord login.

scopes

The scopes to request on every login. The client always adds identify.

scopes?: readonly TScopes[] | undefined

store

Where the tokens are kept, encrypted.

store: TokenStore;