AccessToken
in package
A memoized Access Token, with the ability to auto-refresh when needed.
Tags
Table of Contents
- $access_token : string|null
- $cachedTokenFile : string
- $client : HTTPClient
- $expires_at : int|null
- __construct() : mixed
- fetchAccessToken() : object|null
- getBearerToken() : string|null
- getExpiresAt() : int|null
- resetCachedToken() : void
- updateAccessToken() : void
- logTokenStatus() : void
- A simple log for access token only triggered if in debug mode
- readCachedToken() : void
- storeAccessToken() : mixed
Properties
$access_token
private
string|null
$access_token
= null
$cachedTokenFile
private
string
$cachedTokenFile
$client
private
HTTPClient
$client
$expires_at
private
int|null
$expires_at
= null
Methods
__construct()
public
__construct(HTTPClient $client[, string $cachedTokenFile = __DIR__ . '/cached_token.json' ]) : mixed
Parameters
- $client : HTTPClient
- $cachedTokenFile : string = __DIR__ . '/cached_token.json'
Return values
mixed —fetchAccessToken()
public
fetchAccessToken() : object|null
Return values
object|null —getBearerToken()
public
getBearerToken() : string|null
Return values
string|null —getExpiresAt()
public
getExpiresAt() : int|null
Return values
int|null —resetCachedToken()
public
resetCachedToken() : void
Return values
void —updateAccessToken()
public
updateAccessToken() : void
Return values
void —logTokenStatus()
A simple log for access token only triggered if in debug mode
private
logTokenStatus(string $message) : void
Parameters
- $message : string
Return values
void —readCachedToken()
private
readCachedToken(string $filename) : void
Parameters
- $filename : string
Return values
void —storeAccessToken()
private
storeAccessToken(object $object) : mixed
Parameters
- $object : object