AuthClient

AuthClient

The base of all Auth Clients.

Constructor

new AuthClient()

Members

RequestMethodNameSymbol

Symbols that can be added to GaxiosOptions to specify the method name that is making an RPC call, for logging purposes, as well as a string ID that can be used to correlate calls and responses.

quotaProjectId

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

transporter

The Gaxios instance used for making requests.

RETRY_CONFIG

Retry config for Auth-related requests.

Methods

addSharedMetadataHeaders(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.

Parameters:
Name Type Description
headers

object to append additional headers to.

addUserProjectAndAuthHeaders(target, source)

Adds the x-goog-user-project and authorization headers to the target Headers object, if they exist on the source.

Parameters:
Name Type Description
target

the headers to target

source

the headers to source from

Returns:
Type Description

the target headers

fetch(…args)

A fetch compliant API for AuthClient.

Parameters:
Name Type Attributes Description
args <repeatable>

fetch API or Gaxios#fetch parameters

Returns:
Type Description

the GaxiosResponse with Gaxios-added properties

See:
  • AuthClient.request for the classic method.
Example
```ts
const authClient = new AuthClient();
const fetchWithAuthClient: typeof fetch = (...args) => authClient.fetch(...args);
await fetchWithAuthClient('https://example.com');
```

setCredentials()

Sets the auth credentials.

(static) setMethodName(config, methodName)

Sets the method name that is making a Gaxios request, so that logging may tag log lines with the operation.

Parameters:
Name Type Description
config

A Gaxios request config

methodName

The method name making the call