class FetchAuthTokenCache implements FetchAuthTokenInterface, GetQuotaProjectInterface, SignBlobInterface, ProjectIdProviderInterface, UpdateMetadataInterface (View source)

A class to implement caching for any object implementing FetchAuthTokenInterface

Traits

Methods

__construct(FetchAuthTokenInterface $fetcher, array $cacheConfig = null, CacheItemPoolInterface $cache)

No description

array
fetchAuthToken(callable $httpHandler = null)

Implements FetchAuthTokenInterface#fetchAuthToken.

string
getCacheKey()

No description

null|array
getLastReceivedToken()

No description

string
getClientName(callable $httpHandler = null)

Get the client name from the fetcher.

string
signBlob(string $stringToSign, bool $forceOpenSsl = false)

Sign a blob using the fetcher.

string|null
getQuotaProject()

Get the quota project used for this API request from the credentials fetcher.

string|null
getProjectId(callable $httpHandler = null)

Get the project ID.

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

Updates metadata with the authorization token.

Details

__construct(FetchAuthTokenInterface $fetcher, array $cacheConfig = null, CacheItemPoolInterface $cache)

No description

Parameters

FetchAuthTokenInterface $fetcher

A credentials fetcher

array $cacheConfig

Configuration for the cache

CacheItemPoolInterface $cache

FetchAuthTokenInterface getFetcher()

No description

array fetchAuthToken(callable $httpHandler = null)

Implements FetchAuthTokenInterface#fetchAuthToken.

Checks the cache for a valid auth token and fetches the auth tokens from the supplied fetcher.

Parameters

callable $httpHandler

callback which delivers psr7 request

Return Value

array

a hash of auth tokens

Exceptions

Exception

string getCacheKey()

No description

Return Value

string

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

null|array getLastReceivedToken()

No description

Return Value

null|array

{ The last received access token.

string getClientName(callable $httpHandler = null)

Get the client name from the fetcher.

Parameters

callable $httpHandler

callback which delivers psr7 request, if one is required to obtain a client name.

Return Value

string

string signBlob(string $stringToSign, bool $forceOpenSsl = false)

Sign a blob using the fetcher.

Parameters

string $stringToSign

The string to sign.

bool $forceOpenSsl

Require use of OpenSSL for local signing. Does not apply to signing done using external services. Defaults to false.

Return Value

string

The resulting signature. Value should be base64-encoded.

Exceptions

RuntimeException

string|null getQuotaProject()

Get the quota project used for this API request from the credentials fetcher.

Return Value

string|null

string|null getProjectId(callable $httpHandler = null)

Get the project ID.

Parameters

callable $httpHandler

Callback which delivers psr7 request

Return Value

string|null

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

Exceptions

RuntimeException