PHP Class OAuth2\Service

Show file Open project: vznet/oauth_2.0_client_php

Public Methods

Method Description
__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

Private Methods

Method Description
_parseAccessTokenResponse ( HttpClient $http, string $oldRefreshToken = null ) : Token parse the response of an access token request and store it in dataStore

Method Details

__construct() public method

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() public method

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

callApiEndpoint() public method

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
return string

getAccessToken() public method

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() public method

refresh access token
public refreshAccessToken ( Token $token ) : Token
$token Token
return Token new token object