Class DownscopedClient (7.3.0)

Inheritance

AuthClient > DownscopedClient

Package

google-auth-library!

Constructors

(constructor)(client, cab, additionalOptions)

constructor(client: AuthClient, cab: CredentialAccessBoundary, additionalOptions?: RefreshOptions);

Constructs a new instance of the DownscopedClient class

Parameters
Name Description
client AuthClient
cab CredentialAccessBoundary
additionalOptions RefreshOptions

Properties

authClient

readonly authClient: AuthClient;
Property Value
Type Description
AuthClient

credentialAccessBoundary

readonly credentialAccessBoundary: CredentialAccessBoundary;
Property Value
Type Description
CredentialAccessBoundary

eagerRefreshThresholdMillis

readonly eagerRefreshThresholdMillis: number;
Property Value
Type Description
number

forceRefreshOnFailure

readonly forceRefreshOnFailure: boolean;
Property Value
Type Description
boolean

Methods

getAccessToken()

getAccessToken(): Promise<GetAccessTokenResponse>;
Returns
Type Description
Promise<GetAccessTokenResponse>

getRequestHeaders()

getRequestHeaders(): Promise<Headers>;

The main authentication interface. It takes an optional url which when present is the endpoint> being accessed, and returns a Promise which resolves with authorization header fields.

The result has the form: { Authorization: 'Bearer <access_token_value>' }

Returns
Type Description
Promise<Headers>

refreshAccessTokenAsync()

protected refreshAccessTokenAsync(): Promise<CredentialsWithResponse>;

Forces token refresh, even if unexpired tokens are currently cached. GCP access tokens are retrieved from authclient object/source credential. Thenm GCP access tokens are exchanged for downscoped access tokens via the token exchange endpoint. A promise that resolves with the fresh downscoped access token.

Returns
Type Description
Promise<CredentialsWithResponse>

request(opts)

request<T>(opts: GaxiosOptions): GaxiosPromise<T>;

Provides a request implementation with OAuth 2.0 flow. In cases of HTTP 401 and 403 responses, it automatically asks for a new access token and replays the unsuccessful request.

Parameter
Name Description
opts GaxiosOptions

Request options.

Returns
Type Description
GaxiosPromise<T>
Type Parameter
Name Description
T

request(opts, callback)

request<T>(opts: GaxiosOptions, callback: BodyResponseCallback<T>): void;
Parameters
Name Description
opts GaxiosOptions
callback BodyResponseCallback<T>
Returns
Type Description
void
Type Parameter
Name Description
T

setCredentials(credentials)

setCredentials(credentials: Credentials): void;

Provides a mechanism to inject Downscoped access tokens directly. When the provided credential expires, a new credential, using the external account options are retrieved. Notice DownscopedClient is the broker class mainly used for generate downscoped access tokens, it is unlikely we call this function in real use case. We implement to make this a helper function for testing all cases in getAccessToken().

Parameter
Name Description
credentials Credentials

The Credentials object to set on the current client.

Returns
Type Description
void