PHP Class OAuth2Handler, googleads-php-lib

Afficher le fichier Open project: googleads/googleads-php-lib Class Usage Examples

Méthodes publiques

Méthode Description
CanRefreshAccessToken ( array $credentials ) : boolean Determines if the access token can be refreshed.
FormatCredentialsForHeader ( array $credentials ) : string Formats OAuth2 credentials for use in an HTTP header.
FormatCredentialsForUrl ( array $credentials ) : string Formats OAuth2 credentials for use in a URL.
GetAccessToken ( array $credentials, string $code, string $redirectUri = null ) : array Gets the access token for an authorized request token.
GetAuthorizationUrl ( array $credentials, string $redirectUri = null, boolean $offline = null, array $params = null ) : string Gets the authorization URL to redirect to.
GetOrRefreshAccessToken ( array $credentials ) : array Get the valid access token or the token if needed and possible.
GetScopes ( ) : array Gets OAuth2 scopes.
IsAccessTokenExpiring ( array $credentials ) : boolean Tests if the access token is about to expire or has expired.
IsAccessTokenValid ( array $credentials ) : boolean Determines if the access token is still valid. If expiry information isn't available then this function will assume it is.
RefreshAccessToken ( array $credentials ) : array Refreshes the access token.
SetScopes ( $scopes ) Sets OAuth2 scopes.
ShouldRefreshAccessToken ( array $credentials ) : boolean Determines if the access token should be refreshed.
__construct ( array $scopes = null )

Méthodes protégées

Méthode Description
GetAccessEndpoint ( array $params = null ) : string Gets the access endpoint using the given server and parameters.
GetAuthorizeEndpoint ( array $params = null ) : string Gets the authorization endpoint using the given server and parameters.

Private Methods

Méthode Description
GetEndpoint ( string $endpoint, array $params = null ) : string Gets an endpoint using the given server and parameters.
GetExpiryTimestamp ( array $credentials ) : integer | boolean Get the expiry of a given credential, or false if none is found.

Method Details

CanRefreshAccessToken() public méthode

Determines if the access token can be refreshed.
public CanRefreshAccessToken ( array $credentials ) : boolean
$credentials array the credentials
Résultat boolean true if the credentials can be refreshed

FormatCredentialsForHeader() public méthode

For example: Bearer token
public FormatCredentialsForHeader ( array $credentials ) : string
$credentials array the OAuth2 credentials
Résultat string the credentials formatted for use in an HTTP header

FormatCredentialsForUrl() public méthode

For example: access_token=token.
public FormatCredentialsForUrl ( array $credentials ) : string
$credentials array the OAuth2 credentials
Résultat string the credentials formatted for use in a URL

GetAccessEndpoint() protected méthode

Gets the access endpoint using the given server and parameters.
protected GetAccessEndpoint ( array $params = null ) : string
$params array the parameters to include in the endpoint
Résultat string the access endpoint

GetAccessToken() abstract public méthode

Gets the access token for an authorized request token.
See also: https://developers.google.com/accounts/docs/OAuth2WebServer#handlingtheresponse
abstract public GetAccessToken ( array $credentials, string $code, string $redirectUri = null ) : array
$credentials array the credentials, including client_id and client_secret
$code string the authorization code returned in the response
$redirectUri string optional callback URL
Résultat array the credentials passed in plus access_token, expires_in, timestamp and optionally refresh_token if offline mode was requested

GetAuthorizationUrl() public méthode

Gets the authorization URL to redirect to.
See also: https://developers.google.com/accounts/docs/OAuth2WebServer#formingtheurl
public GetAuthorizationUrl ( array $credentials, string $redirectUri = null, boolean $offline = null, array $params = null ) : string
$credentials array the credentials, including client_id
$redirectUri string optional callback URL
$offline boolean whether or not to request offline access (aka a refresh token), false by default
$params array optional array of additional parameters to include in the URL
Résultat string an authorization URL to redirect the user to

GetAuthorizeEndpoint() protected méthode

Gets the authorization endpoint using the given server and parameters.
protected GetAuthorizeEndpoint ( array $params = null ) : string
$params array the parameters to include in the endpoint
Résultat string the authorization endpoint

GetOrRefreshAccessToken() public méthode

Get the valid access token or the token if needed and possible.
public GetOrRefreshAccessToken ( array $credentials ) : array
$credentials array the credentials, including client_id and client_secret
Résultat array the credentials passed in plus any refreshed credentials if they were refreshed

GetScopes() public méthode

Gets OAuth2 scopes.
public GetScopes ( ) : array
Résultat array the list of OAuth2 scopes

IsAccessTokenExpiring() public méthode

Tests if the access token is about to expire or has expired.
public IsAccessTokenExpiring ( array $credentials ) : boolean
$credentials array the credentials, including access_token, timestamp and expires_in
Résultat boolean true if the token has expired

IsAccessTokenValid() public méthode

Determines if the access token is still valid. If expiry information isn't available then this function will assume it is.
public IsAccessTokenValid ( array $credentials ) : boolean
$credentials array the credentials, including access_token, timestamp and expires_in
Résultat boolean true if the access token is valid or if expiring information isn't available

RefreshAccessToken() abstract public méthode

Refreshes the access token.
See also: https://developers.google.com/accounts/docs/OAuth2WebServer#offline
abstract public RefreshAccessToken ( array $credentials ) : array
$credentials array the credentials, including the client_id, client_secret, refresh_token
Résultat array the credentials

SetScopes() public méthode

Sets OAuth2 scopes.
public SetScopes ( $scopes )

ShouldRefreshAccessToken() public méthode

Determines if the access token should be refreshed.
public ShouldRefreshAccessToken ( array $credentials ) : boolean
$credentials array the credentials, including client_id and client_secret
Résultat boolean true if the Access Token should be refreshed

__construct() public méthode

public __construct ( array $scopes = null )
$scopes array optional, Google API scopes this handler should use