GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • ADK for TypeScript: API Reference

This view

  • Original page
  • New address

GeezerVison is showing adk.dev — AutoAuthCredentialExchanger | ADK for TypeScript: API Reference - v2.5.0

  • AutoAuthCredentialExchanger

Class AutoAuthCredentialExchanger

Automatically selects the appropriate credential exchanger based on the auth scheme. Ported from Python implementation.

Example

// Common case: a built-in exchanger handles the credential.
const exchanger = new AutoAuthCredentialExchanger();
const result = await exchanger.exchange({
authScheme: serviceAccountScheme,
authCredential: serviceAccountCredential,
});
// result.credential carries an OAuth token as a bearer token.

Example

// Use CustomAuthExchanger for OAuth2 instead of the built-in exchanger.
const exchanger = new AutoAuthCredentialExchanger({
[AuthCredentialTypes.OAUTH2]: new CustomAuthExchanger(),
});

Implements

  • BaseCredentialExchanger
  • Defined in core/src/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.ts:105

Constructors

constructor

  • new AutoAuthCredentialExchanger(
        customExchangers?: Partial<
            Record<AuthCredentialTypes, BaseCredentialExchanger>,
        >,
    ): AutoAuthCredentialExchanger

    Parameters

    • OptionalcustomExchangers: Partial<Record<AuthCredentialTypes, BaseCredentialExchanger>>

      Optional exchangers that add to or override the built-in ones. The key is the auth credential type; the value is the exchanger instance to use for that type.

    Returns AutoAuthCredentialExchanger

    • Defined in core/src/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.ts:124

Properties

Readonlyexchangers

exchangers: Map<AuthCredentialTypes, BaseCredentialExchanger> = ...

The exchanger used for each auth credential type.

By default OAUTH2 and OPEN_ID_CONNECT run OAuth2CredentialExchanger and convert any access token with generateAuthToken, and SERVICE_ACCOUNT maps to a ServiceAccountCredentialExchanger, with any custom exchangers from the constructor merged over them. The map is live: an entry added or replaced after construction is used by the next exchange call.

  • Defined in core/src/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.ts:116

Methods

exchange

  • exchange(
        params: { authCredential: AuthCredential; authScheme?: AuthScheme },
    ): Promise<ExchangeResult>

    Exchanges the credential with the exchanger registered for its type.

    Parameters

    • params: { authCredential: AuthCredential; authScheme?: AuthScheme }

    Returns Promise<ExchangeResult>

    The credential unchanged, with wasExchanged: false, when no exchanger is registered for its type. Otherwise the delegate's result, or null when there is no credential at all.

    Implementation of BaseCredentialExchanger.exchange

    • Defined in core/src/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.ts:153
  • exchange(
        params: { authCredential?: AuthCredential; authScheme?: AuthScheme },
    ): Promise<ExchangeResult | null>

    Exchanges the credential with the exchanger registered for its type.

    Parameters

    • params: { authCredential?: AuthCredential; authScheme?: AuthScheme }

    Returns Promise<ExchangeResult | null>

    The credential unchanged, with wasExchanged: false, when no exchanger is registered for its type. Otherwise the delegate's result, or null when there is no credential at all.

    Implementation of BaseCredentialExchanger.exchange

    • Defined in core/src/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.ts:157
Constructors
constructor
Properties
exchangers
Methods
exchange
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.