Configuration options for OAuth2Manager

interface OAuth2Config {
    accessToken?: string;
    additionalHeaders?: Record<string, string>;
    authorizationEndpoint?: string;
    clientId: string;
    clientSecret: string;
    onTokenUpdate?: ((tokens) => void | Promise<void>);
    redirectUri?: string;
    refreshBufferMs?: number;
    refreshToken?: string;
    scopes?: string[];
    tokenEndpoint: string;
    tokenExpiresAt?: number;
    tokenRequestTransform?: ((params) => Record<string, string>);
    tokenResponseTransform?: ((response) => OAuth2TokenResponse);
}

Properties

accessToken?: string

Initial access token (if already obtained)

additionalHeaders?: Record<string, string>

Additional headers to include in token requests

authorizationEndpoint?: string

Authorization endpoint URL (e.g., 'https://api.example.com/oauth/authorize') Only needed for authorization_code flow

clientId: string

OAuth2 client ID

clientSecret: string

OAuth2 client secret

onTokenUpdate?: ((tokens) => void | Promise<void>)

Callback invoked when tokens are updated (for persistence)

Type declaration

    • (tokens): void | Promise<void>
    • Parameters

      Returns void | Promise<void>

redirectUri?: string

Redirect URI for authorization_code flow

refreshBufferMs?: number

Buffer time in milliseconds before token expiration to trigger refresh (default: 60000 = 1 minute)

refreshToken?: string

Initial refresh token (if available)

scopes?: string[]

OAuth2 scopes to request

tokenEndpoint: string

Token endpoint URL (e.g., 'https://api.example.com/oauth/token')

tokenExpiresAt?: number

Initial token expiration timestamp (milliseconds since epoch)

tokenRequestTransform?: ((params) => Record<string, string>)

Custom transformation for token request body (for provider-specific requirements)

Type declaration

    • (params): Record<string, string>
    • Parameters

      • params: Record<string, string>

      Returns Record<string, string>

tokenResponseTransform?: ((response) => OAuth2TokenResponse)

Custom transformation for token response (for non-standard OAuth2 implementations)

Type declaration