class ExternalAccountCredentials implements FetchAuthTokenInterface, UpdateMetadataInterface, GetQuotaProjectInterface, GetUniverseDomainInterface, ProjectIdProviderInterface (View source)

Traits

Provides shared methods for updating request metadata (request headers).

Trait containing helper methods required for enabling observability metrics in the library.

Constants

private EXTERNAL_ACCOUNT_TYPE

private CLOUD_RESOURCE_MANAGER_URL

Properties

static protected string $metricMetadataKey from  MetricsTrait

Methods

static string
getMetricsHeader(string $credType = '', string $authRequestType = '')

No description

array
applyServiceApiUsageMetrics(array $metadata)

No description

array
applyTokenEndpointMetrics(array $metadata, string $authRequestType)

No description

static string
getVersion()

No description

string
getCredType()

No description

callable
getUpdateMetadataFunc() deprecated

export a callback function which updates runtime metadata.

array
updateMetadata(array $metadata, string $authUri = null, callable $httpHandler = null)

Updates metadata with the authorization token.

__construct(string|string[] $scope, array $jsonKey)

No description

array
fetchAuthToken(callable $httpHandler = null)

No description

string
getCacheKey()

Obtains a key that can used to cache the results of #fetchAuthToken.

null|array
getLastReceivedToken()

Returns an associative array with the token and expiration time.

string|null
getQuotaProject()

Get the quota project used for this API request

string
getUniverseDomain()

Get the universe domain used for this API request

string|null
getProjectId(callable $httpHandler = null, string $accessToken = null)

Get the project ID.

Details

static protected string getMetricsHeader(string $credType = '', string $authRequestType = '')

No description

Parameters

string $credType

[Optional] The credential type. Empty value will not add any credential type to the header. Should be one of 'sa', 'jwt', 'imp', 'mds', 'u'.

string $authRequestType

[Optional] The auth request type. Empty value will not add any auth request type to the header. Should be one of 'at', 'it', 'mds'.

Return Value

string

The header value for the observability metrics.

protected array applyServiceApiUsageMetrics(array $metadata)

No description

Parameters

array $metadata

The metadata to update and return.

Return Value

array

The updated metadata.

protected array applyTokenEndpointMetrics(array $metadata, string $authRequestType)

No description

Parameters

array $metadata

The metadata to update and return.

string $authRequestType

The auth request type. Possible values are 'at', 'it', 'mds'.

Return Value

array

The updated metadata.

static protected string getVersion()

No description

Return Value

string

protected string getCredType()

No description

Return Value

string

callable getUpdateMetadataFunc() deprecated

deprecated

export a callback function which updates runtime metadata.

Return Value

callable

updateMetadata function

array updateMetadata(array $metadata, string $authUri = null, callable $httpHandler = null)

Updates metadata with the authorization token.

Parameters

array $metadata

metadata hashmap

string $authUri

optional auth uri

callable $httpHandler

callback which delivers psr7 request

Return Value

array

updated metadata hashmap

__construct(string|string[] $scope, array $jsonKey)

No description

Parameters

string|string[] $scope

The scope of the access request, expressed either as an array or as a space-delimited string.

array $jsonKey

JSON credentials as an associative array.

array fetchAuthToken(callable $httpHandler = null)

No description

Parameters

callable $httpHandler

callback which delivers psr7 request

Return Value

array

a hash of auth tokens

string getCacheKey()

Obtains a key that can used to cache the results of #fetchAuthToken.

If the value is empty, the auth token is not cached.

Return Value

string

a key that may be used to cache the auth token.

null|array getLastReceivedToken()

Returns an associative array with the token and expiration time.

Return Value

null|array

{ The last received access token.

@type string $access_token The access token string.
@type int $expires_at The time the token expires as a UNIX timestamp.

}

string|null getQuotaProject()

Get the quota project used for this API request

Return Value

string|null

string getUniverseDomain()

Get the universe domain used for this API request

Return Value

string

string|null getProjectId(callable $httpHandler = null, string $accessToken = null)

Get the project ID.

Parameters

callable $httpHandler

Callback which delivers psr7 request

string $accessToken

The access token to use to sign the blob. If provided, saves a call to the metadata server for a new access token. Defaults to null.

Return Value

string|null