PHP Class EOAuth2Service

Inheritance: extends EAuthServiceBase, implements IAuthService
ファイルを表示 Open project: nodge/yii-eauth Class Usage Examples

Protected Properties

Property Type Description
$access_token current OAuth2 access token.
$client_id OAuth2 client id.
$client_secret OAuth2 client secret key.
$errorAccessDeniedCode Error code for access_denied response.
$errorDescriptionParam Error description key name in _GET options.
$errorParam Error key name in _GET options.
$providerOptions Provider options. Must contain the keys: authorize, access_token.
$scope OAuth scopes.

Public Methods

Method Description
authenticate ( ) : boolean Authenticate the user.
init ( $component, $options = [] )
makeSignedRequest ( string $url, array $options = [], boolean $parseJson = true ) : stdClass Returns the protected resource.

Protected Methods

Method Description
getAccessToken ( string $code ) : string Returns the OAuth2 access token.
getCodeUrl ( string $redirect_uri ) : string Returns the url to request to get OAuth2 code.
getSignedRequestFields ( ) : array Returns fields required for signed request.
getTokenUrl ( string $code ) : string Returns the url to request to get OAuth2 access token.
restoreAccessToken ( ) : boolean Restore access token from the session.
saveAccessToken ( string $token ) Save access token to the session.

Method Details

authenticate() public method

Authenticate the user.
public authenticate ( ) : boolean
return boolean whether user was successfuly authenticated.

getAccessToken() protected method

Returns the OAuth2 access token.
protected getAccessToken ( string $code ) : string
$code string the OAuth2 code. See {@link getCodeUrl}.
return string the token.

getCodeUrl() protected method

Returns the url to request to get OAuth2 code.
protected getCodeUrl ( string $redirect_uri ) : string
$redirect_uri string url to redirect after user confirmation.
return string url to request.

getSignedRequestFields() protected method

By default returns array('access_token' => $this->access_token). Used in {@link makeSignedRequest}.
protected getSignedRequestFields ( ) : array
return array

getTokenUrl() protected method

Returns the url to request to get OAuth2 access token.
protected getTokenUrl ( string $code ) : string
$code string
return string url to request.

init() public method

public init ( $component, $options = [] )

makeSignedRequest() public method

Returns the protected resource.
See also: makeRequest
public makeSignedRequest ( string $url, array $options = [], boolean $parseJson = true ) : stdClass
$url string url to request.
$options array HTTP request options. Keys: query, data, referer.
$parseJson boolean Whether to parse response in json format.
return stdClass the response.

restoreAccessToken() protected method

Restore access token from the session.
protected restoreAccessToken ( ) : boolean
return boolean whether the access token was successfuly restored.

saveAccessToken() protected method

Save access token to the session.
protected saveAccessToken ( string $token )
$token string access token.

Property Details

$access_token protected_oe property

current OAuth2 access token.
protected $access_token

$client_id protected_oe property

OAuth2 client id.
protected $client_id

$client_secret protected_oe property

OAuth2 client secret key.
protected $client_secret

$errorAccessDeniedCode protected_oe property

Error code for access_denied response.
protected $errorAccessDeniedCode

$errorDescriptionParam protected_oe property

Error description key name in _GET options.
protected $errorDescriptionParam

$errorParam protected_oe property

Error key name in _GET options.
protected $errorParam

$providerOptions protected_oe property

Provider options. Must contain the keys: authorize, access_token.
protected $providerOptions

$scope protected_oe property

OAuth scopes.
protected $scope