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
NameDescription
headers Headers

object to append additional headers to.

Returns
TypeDescription
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
TypeDescription
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
NameDescription
url string

The URI being authorized.

Returns
TypeDescription
Promise<Headers>

request(opts)

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

Provides an alternative Gaxios request implementation with auth credentials

Parameter
NameDescription
opts GaxiosOptions
Returns
TypeDescription
GaxiosPromise<T>
Type Parameter
NameDescription
T

setCredentials(credentials)

setCredentials(credentials: Credentials): void;

Sets the auth credentials.

Parameter
NameDescription
credentials Credentials
Returns
TypeDescription
void