FetchAuthTokenCache
in package
implements
FetchAuthTokenInterface, GetQuotaProjectInterface, SignBlobInterface, ProjectIdProviderInterface, UpdateMetadataInterface
uses
CacheTrait
A class to implement caching for any object implementing FetchAuthTokenInterface
Table of Contents
Interfaces
- FetchAuthTokenInterface
- An interface implemented by objects that can fetch auth tokens.
- GetQuotaProjectInterface
- An interface implemented by objects that can get quota projects.
- SignBlobInterface
- Describes a class which supports signing arbitrary strings.
- ProjectIdProviderInterface
- Describes a Credentials object which supports fetching the project ID.
- UpdateMetadataInterface
- Describes a Credentials object which supports updating request metadata (request headers).
Properties
- $cache : CacheItemPoolInterface
- $cacheConfig : array<string|int, mixed>
- $fetcher : FetchAuthTokenInterface
- $maxKeyLength : mixed
Methods
- __construct() : mixed
- fetchAuthToken() : array<string|int, mixed>
- Implements FetchAuthTokenInterface#fetchAuthToken.
- getCacheKey() : string
- Obtains a key that can used to cache the results of #fetchAuthToken.
- getClientName() : string
- Get the client name from the fetcher.
- getLastReceivedToken() : array<string|int, mixed>|null
- Returns an associative array with the token and expiration time.
- getProjectId() : string|null
- Get the project ID.
- getQuotaProject() : string|null
- Get the quota project used for this API request from the credentials fetcher.
- signBlob() : string
- Sign a blob using the fetcher.
- updateMetadata() : array<string|int, mixed>
- Updates metadata with the authorization token.
- fetchAuthTokenFromCache() : mixed
- getCachedValue() : mixed
- Gets the cached value if it is present in the cache when that is available.
- getFullCacheKey() : mixed
- saveAuthTokenInCache() : mixed
- setCachedValue() : mixed
- Saves the value in the cache when that is available.
Properties
$cache
private
CacheItemPoolInterface
$cache
$cacheConfig
private
array<string|int, mixed>
$cacheConfig
$fetcher
private
FetchAuthTokenInterface
$fetcher
$maxKeyLength
private
mixed
$maxKeyLength
= 64
Methods
__construct()
public
__construct(FetchAuthTokenInterface $fetcher[, array<string|int, mixed> $cacheConfig = null ], CacheItemPoolInterface $cache) : mixed
Parameters
- $fetcher : FetchAuthTokenInterface
-
A credentials fetcher
- $cacheConfig : array<string|int, mixed> = null
-
Configuration for the cache
- $cache : CacheItemPoolInterface
fetchAuthToken()
Implements FetchAuthTokenInterface#fetchAuthToken.
public
fetchAuthToken([callable $httpHandler = null ]) : array<string|int, mixed>
Checks the cache for a valid auth token and fetches the auth tokens from the supplied fetcher.
Parameters
- $httpHandler : callable = null
-
callback which delivers psr7 request
Tags
Return values
array<string|int, mixed> —the response
getCacheKey()
Obtains a key that can used to cache the results of #fetchAuthToken.
public
getCacheKey() : string
Return values
stringgetClientName()
Get the client name from the fetcher.
public
getClientName([callable $httpHandler = null ]) : string
Parameters
- $httpHandler : callable = null
-
An HTTP handler to deliver PSR7 requests.
Return values
stringgetLastReceivedToken()
Returns an associative array with the token and expiration time.
public
getLastReceivedToken() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetProjectId()
Get the project ID.
public
getProjectId([callable $httpHandler = null ]) : string|null
Parameters
- $httpHandler : callable = null
-
Callback which delivers psr7 request
Return values
string|nullgetQuotaProject()
Get the quota project used for this API request from the credentials fetcher.
public
getQuotaProject() : string|null
Return values
string|nullsignBlob()
Sign a blob using the fetcher.
public
signBlob(string $stringToSign[, bool $forceOpenSsl = false ]) : string
Parameters
- $stringToSign : string
-
The string to sign.
- $forceOpenSsl : bool = false
-
Require use of OpenSSL for local signing. Does not apply to signing done using external services. Defaults to
false
.
Tags
Return values
string —The resulting signature.
updateMetadata()
Updates metadata with the authorization token.
public
updateMetadata(array<string|int, mixed> $metadata[, string $authUri = null ][, callable $httpHandler = null ]) : array<string|int, mixed>
Parameters
- $metadata : array<string|int, mixed>
-
metadata hashmap
- $authUri : string = null
-
optional auth uri
- $httpHandler : callable = null
-
callback which delivers psr7 request
Tags
Return values
array<string|int, mixed> —updated metadata hashmap
fetchAuthTokenFromCache()
private
fetchAuthTokenFromCache([mixed $authUri = null ]) : mixed
Parameters
- $authUri : mixed = null
getCachedValue()
Gets the cached value if it is present in the cache when that is available.
private
getCachedValue(mixed $k) : mixed
Parameters
- $k : mixed
getFullCacheKey()
private
getFullCacheKey(mixed $key) : mixed
Parameters
- $key : mixed
saveAuthTokenInCache()
private
saveAuthTokenInCache(mixed $authToken[, mixed $authUri = null ]) : mixed
Parameters
- $authToken : mixed
- $authUri : mixed = null
setCachedValue()
Saves the value in the cache when that is available.
private
setCachedValue(mixed $k, mixed $v) : mixed
Parameters
- $k : mixed
- $v : mixed