@mcp-z/client
    Preparing search index...

    Class InteractiveOAuthFlow

    InteractiveOAuthFlow manages the complete OAuth authorization code flow

    Index
    • Perform OAuth authorization code flow

      Parameters

      • authorizationEndpoint: string

        OAuth authorization endpoint URL

      • tokenEndpoint: string

        OAuth token endpoint URL

      • clientId: string

        OAuth client ID

      • clientSecret: string

        OAuth client secret

      • options: OAuthFlowOptions

        Flow options (port is required - use get-port to find available port)

      Returns Promise<TokenSet>

      Token set with access and refresh tokens

      Error if flow fails or times out

      import getPort from 'get-port';

      const flow = new InteractiveOAuthFlow();
      const port = await getPort({ host: 'localhost' });
      const tokens = await flow.performAuthFlow(
      'https://example.com/oauth/authorize',
      'https://example.com/oauth/token',
      'client-id',
      'client-secret',
      { port, issuer: 'https://example.com', resource: 'https://example.com/mcp', scopes: ['read', 'write'] }
      );
    • Refreshes an access token using a refresh token.

      Parameters

      • tokenEndpoint: string

        OAuth token endpoint URL.

      • refreshToken: string

        Refresh token from a previous token set.

      • clientId: string

        OAuth client ID.

      • clientSecret: string

        OAuth client secret.

      • resource: string

        Canonical resource server URI, audience-binding the token (RFC 8707).

      • allowLoopback: boolean = false

        Loopback trust grant computed by the caller from the server it is actually talking to, never from tokenEndpoint. Defaults to false.

      • Optionalsignal: AbortSignal

      Returns Promise<TokenSet>

      New token set with a refreshed access token.

      Error if refresh fails.