Class DownscopedClient (7.2.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
NameDescription
client AuthClient
cab CredentialAccessBoundary
additionalOptions RefreshOptions

Properties

authClient

readonly authClient: AuthClient;
Property Value
TypeDescription
AuthClient

credentialAccessBoundary

readonly credentialAccessBoundary: CredentialAccessBoundary;
Property Value
TypeDescription
CredentialAccessBoundary

eagerRefreshThresholdMillis

readonly eagerRefreshThresholdMillis: number;
Property Value
TypeDescription
number

forceRefreshOnFailure

readonly forceRefreshOnFailure: boolean;
Property Value
TypeDescription
boolean

Methods

getAccessToken()

getAccessToken(): Promise<GetAccessTokenResponse>;
Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
NameDescription
opts GaxiosOptions

Request options.

Returns
TypeDescription
GaxiosPromise<T>
Type Parameter
NameDescription
T

request(opts, callback)

request<T>(opts: GaxiosOptions, callback: BodyResponseCallback<T>): void;
Parameters
NameDescription
opts GaxiosOptions
callback BodyResponseCallback<T>
Returns
TypeDescription
void
Type Parameter
NameDescription
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
NameDescription
credentials Credentials

The Credentials object to set on the current client.

Returns
TypeDescription
void