PHP Класс OAuth2Handler, googleads-php-lib

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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 )

Защищенные методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

CanRefreshAccessToken() публичный Метод

Determines if the access token can be refreshed.
public CanRefreshAccessToken ( array $credentials ) : boolean
$credentials array the credentials
Результат boolean true if the credentials can be refreshed

FormatCredentialsForHeader() публичный Метод

For example: Bearer token
public FormatCredentialsForHeader ( array $credentials ) : string
$credentials array the OAuth2 credentials
Результат string the credentials formatted for use in an HTTP header

FormatCredentialsForUrl() публичный Метод

For example: access_token=token.
public FormatCredentialsForUrl ( array $credentials ) : string
$credentials array the OAuth2 credentials
Результат string the credentials formatted for use in a URL

GetAccessEndpoint() защищенный Метод

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
Результат string the access endpoint

GetAccessToken() абстрактный публичный Метод

Gets the access token for an authorized request token.
См. также: 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
Результат array the credentials passed in plus access_token, expires_in, timestamp and optionally refresh_token if offline mode was requested

GetAuthorizationUrl() публичный Метод

Gets the authorization URL to redirect to.
См. также: 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
Результат string an authorization URL to redirect the user to

GetAuthorizeEndpoint() защищенный Метод

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
Результат string the authorization endpoint

GetOrRefreshAccessToken() публичный Метод

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
Результат array the credentials passed in plus any refreshed credentials if they were refreshed

GetScopes() публичный Метод

Gets OAuth2 scopes.
public GetScopes ( ) : array
Результат array the list of OAuth2 scopes

IsAccessTokenExpiring() публичный Метод

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
Результат boolean true if the token has expired

IsAccessTokenValid() публичный Метод

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
Результат boolean true if the access token is valid or if expiring information isn't available

RefreshAccessToken() абстрактный публичный Метод

Refreshes the access token.
См. также: 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
Результат array the credentials

SetScopes() публичный Метод

Sets OAuth2 scopes.
public SetScopes ( $scopes )

ShouldRefreshAccessToken() публичный Метод

Determines if the access token should be refreshed.
public ShouldRefreshAccessToken ( array $credentials ) : boolean
$credentials array the credentials, including client_id and client_secret
Результат boolean true if the Access Token should be refreshed

__construct() публичный Метод

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