Class AuthClient (8.7.0)

Inheritance

EventEmitter > AuthClient

Package

google-auth-library

Properties

credentials

credentials: Credentials;

eagerRefreshThresholdMillis

eagerRefreshThresholdMillis: number;

forceRefreshOnFailure

forceRefreshOnFailure: boolean;

projectId

projectId?: string | null;

quotaProjectId

quotaProjectId?: string;

The quota project ID. The quota project can be used by client libraries for the billing purpose. See Working with quotas

transporter

transporter: DefaultTransporter;

Methods

addSharedMetadataHeaders(headers)

protected addSharedMetadataHeaders(headers: Headers): Headers;

Append additional headers, e.g., x-goog-user-project, shared across the classes inheriting AuthClient. This method should be used by any method that overrides getRequestMetadataAsync(), which is a shared helper for setting request information in both gRPC and HTTP API calls.

Parameter
Name Description
headers Headers

object to append additional headers to.

Returns
Type Description
Headers

getAccessToken()

abstract getAccessToken(): Promise<{
        token?: string | null;
        res?: GaxiosResponse | null;
    }>;

A promise that resolves with the current GCP access token response. If the current credential is expired, a new one is retrieved.

Returns
Type Description
Promise<{ token?: string | null; res?: GaxiosResponse | null; }>

getRequestHeaders(url)

abstract getRequestHeaders(url?: string): 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>' }

Parameter
Name Description
url string

The URI being authorized.

Returns
Type Description
Promise<Headers>

request(opts)

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

Provides an alternative Gaxios request implementation with auth credentials

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

setCredentials(credentials)

setCredentials(credentials: Credentials): void;

Sets the auth credentials.

Parameter
Name Description
credentials Credentials
Returns
Type Description
void