PHP Class Webiny\Component\OAuth2\AbstractServer

This class must be extended by every OAuth2 server class. The class provides universal methods for communicating with selected OAuth2 server.
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
__construct ( OAuth2 $oauth2 ) Base constructor.
getAccessTokenUrl ( ) : string Returns the path to the page where we request the access token.
getAuthorizeUrl ( ) : string Returns the path to OAuth2 authorize page.
getServerName ( ) : string Returns the server name.
getUserDetails ( ) : OAuth2User Tries to get user details for the current OAuth2 server.

Protected Methods

Method Description
getUserDetailsTargetData ( ) : array Returns an array [url, params].
processUserDetails ( array $result ) : OAuth2User This method is called automatically when the OAuth2 server returns a response containing user details.

Private Methods

Method Description
rawRequest ( string $url, array $parameters = [] ) : array Preforms an raw request on the current OAuth2 server.

Method Details

__construct() public method

Base constructor.
public __construct ( OAuth2 $oauth2 )
$oauth2 OAuth2

getAccessTokenUrl() abstract public method

Returns the path to the page where we request the access token.
abstract public getAccessTokenUrl ( ) : string
return string Url to access token page.

getAuthorizeUrl() abstract public method

Returns the path to OAuth2 authorize page.
abstract public getAuthorizeUrl ( ) : string
return string Url to OAuth2 authorize page.

getServerName() abstract public method

Returns the server name.
abstract public getServerName ( ) : string
return string

getUserDetails() public method

If you wish to get full account details you must use the rawRequest method because this one returns only the standardized response in a form of OAuth2User object.
public getUserDetails ( ) : OAuth2User
return OAuth2User

getUserDetailsTargetData() abstract protected method

'url' - holds the destination url for accessing user details on the OAuth2 server. 'params' - an optional array of additional parameters that would be sent together with the request.
abstract protected getUserDetailsTargetData ( ) : array
return array

processUserDetails() abstract protected method

The method should process the response an return and instance of OAuth2User.
abstract protected processUserDetails ( array $result ) : OAuth2User
$result array OAuth2 server response.
return OAuth2User