Abstract Class yii\authclient\BaseOAuth

Inheritanceyii\authclient\BaseOAuth » yii\authclient\BaseClient » yii\base\Component » yii\base\BaseObject
Implementsyii\authclient\ClientInterface, yii\base\Configurable
Subclassesyii\authclient\OAuth1, yii\authclient\OAuth2, yii\authclient\OpenIdConnect, yii\authclient\clients\Facebook, yii\authclient\clients\GitHub, yii\authclient\clients\Google, yii\authclient\clients\GoogleHybrid, yii\authclient\clients\LinkedIn, yii\authclient\clients\Live, yii\authclient\clients\Twitter, yii\authclient\clients\TwitterOAuth2, yii\authclient\clients\VKontakte, yii\authclient\clients\Yandex
Available since version2.0
Source Code https://github.com/yiisoft/yii2-authclient/blob/master/BaseOAuth.php

BaseOAuth is a base class for the OAuth clients.

See also http://oauth.net/.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$apiBaseUrl string API base URL. yii\authclient\BaseOAuth
$authUrl string Authorize URL. yii\authclient\BaseOAuth
$autoRefreshAccessToken boolean Whether to automatically perform 'refresh access token' request on expired access token. yii\authclient\BaseOAuth
$parametersToKeepInReturnUrl array List of the parameters to keep in default return url. yii\authclient\BaseOAuth
$scope string Auth request scope. yii\authclient\BaseOAuth
$version string Protocol version. yii\authclient\BaseOAuth

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. yii\base\BaseObject
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
api() Performs request to the OAuth API returning response data. yii\authclient\BaseOAuth
applyAccessTokenToRequest() Applies access token to the HTTP request instance. yii\authclient\BaseOAuth
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
beforeApiRequestSend() Handles \yii\httpclient\Request::EVENT_BEFORE_SEND event. yii\authclient\BaseOAuth
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
className() Returns the fully qualified name of this class. yii\base\BaseObject
createApiRequest() Creates an HTTP request for the API call. yii\authclient\BaseOAuth
createRequest() Creates HTTP request instance. yii\authclient\BaseClient
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
getAccessToken() yii\authclient\BaseOAuth
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getHttpClient() Returns HTTP client. yii\authclient\BaseClient
getId() yii\authclient\ClientInterface
getName() yii\authclient\ClientInterface
getNormalizeUserAttributeMap() yii\authclient\BaseClient
getRequestOptions() yii\authclient\BaseClient
getReturnUrl() yii\authclient\BaseOAuth
getSignatureMethod() yii\authclient\BaseOAuth
getStateStorage() yii\authclient\BaseClient
getTitle() yii\authclient\ClientInterface
getUserAttributes() yii\authclient\ClientInterface
getViewOptions() yii\authclient\ClientInterface
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() Initializes the object. yii\base\BaseObject
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
refreshAccessToken() Gets new auth token to replace expired one. yii\authclient\BaseOAuth
setAccessToken() Sets access token to be used. yii\authclient\BaseOAuth
setHttpClient() {@inheritdoc} yii\authclient\BaseOAuth
setId() yii\authclient\ClientInterface
setName() yii\authclient\ClientInterface
setNormalizeUserAttributeMap() yii\authclient\BaseClient
setRequestOptions() yii\authclient\BaseClient
setReturnUrl() yii\authclient\BaseOAuth
setSignatureMethod() Set signature method to be used. yii\authclient\BaseOAuth
setStateStorage() yii\authclient\BaseClient
setTitle() yii\authclient\ClientInterface
setUserAttributes() yii\authclient\BaseClient
setViewOptions() yii\authclient\BaseClient
trigger() Triggers an event. yii\base\Component

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
composeUrl() Composes URL from base URL and GET params. yii\authclient\BaseOAuth
createHttpClient() {@inheritdoc} yii\authclient\BaseOAuth
createSignatureMethod() Creates signature method instance from its configuration. yii\authclient\BaseOAuth
createToken() Creates token from its configuration. yii\authclient\BaseOAuth
defaultName() Generates service name. yii\authclient\BaseClient
defaultNormalizeUserAttributeMap() Returns the default \yii\authclient\normalizeUserAttributeMap value. yii\authclient\BaseClient
defaultRequestOptions() {@inheritdoc} yii\authclient\BaseOAuth
defaultReturnUrl() Composes default \yii\authclient\returnUrl value. yii\authclient\BaseOAuth
defaultTitle() Generates service title. yii\authclient\BaseClient
defaultViewOptions() Returns the default \yii\authclient\viewOptions value. yii\authclient\BaseClient
getState() Returns persistent state value. yii\authclient\BaseClient
getStateKeyPrefix() Returns session key prefix, which is used to store internal states. yii\authclient\BaseClient
initUserAttributes() Initializes authenticated user attributes. yii\authclient\BaseClient
normalizeUserAttributes() Normalize given user attributes according to \yii\authclient\normalizeUserAttributeMap. yii\authclient\BaseClient
removeState() Removes persistent state value. yii\authclient\BaseClient
restoreAccessToken() Restores access token. yii\authclient\BaseOAuth
saveAccessToken() Saves token as persistent state. yii\authclient\BaseOAuth
sendRequest() Sends the given HTTP request, returning response data. yii\authclient\BaseOAuth
setState() Sets persistent state. yii\authclient\BaseClient

Property Details

$apiBaseUrl public property

API base URL. This field will be used as \yii\httpclient\Client::baseUrl value of \yii\authclient\httpClient. Note: changing this property will take no effect after \yii\authclient\httpClient is instantiated.

public string $apiBaseUrl null
$authUrl public property

Authorize URL.

public string $authUrl null
$autoRefreshAccessToken public property (available since version 2.0.6)

Whether to automatically perform 'refresh access token' request on expired access token.

$parametersToKeepInReturnUrl public property (available since version 2.2.4)

List of the parameters to keep in default return url.

public array $parametersToKeepInReturnUrl = ['authclient']
$scope public property

Auth request scope.

public string $scope null
$version public property

Protocol version.

public string $version '1.0'

Method Details

api() public method

Performs request to the OAuth API returning response data.

You may use createApiRequest() method instead, gaining more control over request execution.

See also createApiRequest().

public array api ( $apiSubUrl, $method 'GET', $data = [], $headers = [] )
$apiSubUrl string

API sub URL, which will be append to $apiBaseUrl, or absolute API URL.

$method string

Request method.

$data array|string

Request data or content.

$headers array

Additional request headers.

return array

API response data.

applyAccessTokenToRequest() public abstract method (available since version 2.1)

Applies access token to the HTTP request instance.

public abstract void applyAccessTokenToRequest ( $request, $accessToken )
$request \yii\httpclient\Request

HTTP request instance.

$accessToken yii\authclient\OAuthToken

Access token instance.

beforeApiRequestSend() public method (available since version 2.1)

Handles \yii\httpclient\Request::EVENT_BEFORE_SEND event.

Applies \yii\authclient\accessToken to the request.

public void beforeApiRequestSend ( $event )
$event \yii\httpclient\RequestEvent

Event instance.

throws yii\base\Exception

on invalid access token.

composeUrl() protected method

Composes URL from base URL and GET params.

protected string composeUrl ( $url, array $params = [] )
$url string

Base URL.

$params array

GET params.

return string

Composed URL.

createApiRequest() public method (available since version 2.1)

Creates an HTTP request for the API call.

The created request will be automatically processed adding access token parameters and signature before sending. You may use createRequest() to gain full control over request composition and execution.

See also createRequest().

public \yii\httpclient\Request createApiRequest ( )
return \yii\httpclient\Request

HTTP request instance.

createHttpClient() protected method

{@inheritdoc}

protected void createHttpClient ( $reference )
$reference
createSignatureMethod() protected method

Creates signature method instance from its configuration.

protected yii\authclient\signature\BaseMethod createSignatureMethod ( array $signatureMethodConfig )
$signatureMethodConfig array

Signature method configuration.

return yii\authclient\signature\BaseMethod

Signature method instance.

createToken() protected method

Creates token from its configuration.

protected yii\authclient\OAuthToken createToken ( array $tokenConfig = [] )
$tokenConfig array

Token configuration.

return yii\authclient\OAuthToken

Token instance.

defaultRequestOptions() protected method

{@inheritdoc}

protected void defaultRequestOptions ( )
defaultReturnUrl() protected method

Composes default \yii\authclient\returnUrl value.

protected string defaultReturnUrl ( )
return string

Return URL.

getAccessToken() public method

public yii\authclient\OAuthToken getAccessToken ( )
return yii\authclient\OAuthToken

Auth token instance.

getReturnUrl() public method

public string getReturnUrl ( )
return string

Return URL.

getSignatureMethod() public method

public yii\authclient\signature\BaseMethod getSignatureMethod ( )
return yii\authclient\signature\BaseMethod

Signature method instance.

refreshAccessToken() public abstract method

Gets new auth token to replace expired one.

public abstract yii\authclient\OAuthToken refreshAccessToken ( yii\authclient\OAuthToken $token )
$token yii\authclient\OAuthToken

Expired auth token.

return yii\authclient\OAuthToken

New auth token.

restoreAccessToken() protected method

Restores access token.

protected yii\authclient\OAuthToken restoreAccessToken ( )
return yii\authclient\OAuthToken

Auth token.

saveAccessToken() protected method

Saves token as persistent state.

protected $this saveAccessToken ( $token )
$token yii\authclient\OAuthToken|null

Auth token to be saved.

return $this

The object itself.

sendRequest() protected method (available since version 2.1)

Sends the given HTTP request, returning response data.

protected array sendRequest ( $request )
$request \yii\httpclient\Request

HTTP request to be sent.

return array

Response data.

throws yii\authclient\InvalidResponseException

on invalid remote response.

setAccessToken() public method

Sets access token to be used.

public void setAccessToken ( $token )
$token array|yii\authclient\OAuthToken|null

Access token or its configuration. Set to null to restore token from token store.

setHttpClient() public method

{@inheritdoc}

public void setHttpClient ( $httpClient )
$httpClient
setReturnUrl() public method

public void setReturnUrl ( $returnUrl )
$returnUrl string

Return URL

setSignatureMethod() public method

Set signature method to be used.

public void setSignatureMethod ( $signatureMethod )
$signatureMethod array|yii\authclient\signature\BaseMethod

Signature method instance or its array configuration.

throws yii\base\InvalidArgumentException

on wrong argument.