PHP Класс OAuth2\Service

Показать файл Открыть проект

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

Метод Описание
__construct ( Client $client, Configuration $configuration, oauth2\DataStore $dataStore, string $scope = null )
authorize ( array $userParameters = [] ) redirect to authorize endpoint of service
callApiEndpoint ( string $endpoint, string $method = 'GET', array $uriParameters = [], mixed $postBody = null, array $additionalHeaders = [] ) : string call an api endpoint. automatically adds needed authorization headers with access token or parameters
getAccessToken ( string $code = null ) get access token of from service, has to be called after successful authorization
refreshAccessToken ( Token $token ) : Token refresh access token

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

Метод Описание
_parseAccessTokenResponse ( HttpClient $http, string $oldRefreshToken = null ) : Token parse the response of an access token request and store it in dataStore

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

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

public __construct ( Client $client, Configuration $configuration, oauth2\DataStore $dataStore, string $scope = null )
$client Client
$configuration OAuth2\Service\Configuration
$dataStore oauth2\DataStore
$scope string optional

authorize() публичный метод

redirect to authorize endpoint of service
public authorize ( array $userParameters = [] )
$userParameters array

callApiEndpoint() публичный метод

call an api endpoint. automatically adds needed authorization headers with access token or parameters
public callApiEndpoint ( string $endpoint, string $method = 'GET', array $uriParameters = [], mixed $postBody = null, array $additionalHeaders = [] ) : string
$endpoint string
$method string default 'GET'
$uriParameters array optional
$postBody mixed optional, can be string or array
$additionalHeaders array
Результат string

getAccessToken() публичный метод

get access token of from service, has to be called after successful authorization
public getAccessToken ( string $code = null )
$code string optional, if no code given method tries to get it out of $_GET

refreshAccessToken() публичный метод

refresh access token
public refreshAccessToken ( Token $token ) : Token
$token Token
Результат Token new token object