Vana SDK - v3.5.0
    Preparing search index...

    Class OAuthClient

    OAuth 2.0 Authorization Code + PKCE client.

    Storage layout under the supplied TokenStore (all keys namespaced):

    • oauth:tokens:{clientId} → access token record
    • oauth:refresh:{clientId} → refresh token record (no expiry)
    • oauth:verifier:{state} → in-flight PKCE verifier (10 min TTL)
    Index

    Methods

    • Build the authorize URL and persist the PKCE verifier keyed by state.

      Parameters

      • opts: { state?: string; scope?: string; extraParams?: Record<string, string> } = {}

      Returns Promise<AuthorizationUrlResult>

    • Handle the redirect-callback URL. Validates state, retrieves the saved verifier, exchanges the authorization code + verifier for tokens, and persists them. Returns the access TokenRecord.

      Parameters

      • callbackUrl: string

      Returns Promise<TokenRecord>

    • Get the current access token if valid (refreshing first if expired and a refresh token is available). Returns null when no usable token exists.

      Returns Promise<string | null>

    • Forget tokens (logout). Does NOT call any remote revocation endpoint.

      Returns Promise<void>