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(),
});
Constructors
constructor
-
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
Properties
Methods
exchange
-
Exchanges the credential with the exchanger registered for its type.
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.
-
Exchanges the credential with the exchanger registered for its type.
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.
Constructors
Properties
Methods