\Google\AdsApi\Common\UtilOAuth2TokenRefresher

Provides functionality with retrieving OAuth2 access tokens using an OAuth2 token fetcher, handling refreshing the token if it's about to expire.

Summary

Methods
Properties
Constants
__construct()
getOrFetchAccessToken()
getAccessTokenRefreshWindow()
setAccessTokenRefreshWindow()
No public properties found
DEFAULT_REFRESH_WINDOW_SECONDS
No protected methods found
No protected properties found
N/A
shouldFetchAccessToken()
$refreshWindowSeconds
N/A

Constants

DEFAULT_REFRESH_WINDOW_SECONDS

DEFAULT_REFRESH_WINDOW_SECONDS

Properties

$refreshWindowSeconds

$refreshWindowSeconds :

Type

Methods

__construct()

__construct(integer|null  $refreshWindowSeconds = null)

Creates an OAuth2 token refresher with an optional, custom refresh window.

Parameters

integer|null $refreshWindowSeconds

optional, the access token refresh window, in seconds

getOrFetchAccessToken()

getOrFetchAccessToken(\Google\Auth\FetchAuthTokenInterface  $fetchAuthTokenInterface,callable|null  $httpHandler = null): string|null

Gets the existing access token, or fetches a new one if an existing one is about to expire within the refresh window, or fetches a new one if there is no existing access token.

Parameters

\Google\Auth\FetchAuthTokenInterface $fetchAuthTokenInterface

the underlying OAuth2 access token fetcher

callable|null $httpHandler

the HTTP handler for making requests to refresh OAuth2 credentials

Returns

string|null

getAccessTokenRefreshWindow()

getAccessTokenRefreshWindow(): integer

Gets the access token refresh window in seconds.

Returns

integer

setAccessTokenRefreshWindow()

setAccessTokenRefreshWindow(integer  $refreshWindowSeconds)

Sets the access token refresh window in seconds.

Parameters

integer $refreshWindowSeconds

shouldFetchAccessToken()

shouldFetchAccessToken(\Google\Auth\FetchAuthTokenInterface  $fetchAuthTokenInterface)

Parameters

\Google\Auth\FetchAuthTokenInterface $fetchAuthTokenInterface