Abstract Class yii\authclient\BaseOAuth

Inheritanceyii\authclient\BaseOAuth » yii\authclient\BaseClient » yii\base\Component » yii\base\Object
Implementsyii\authclient\ClientInterface, yii\base\Configurable
Subclassesyii\authclient\OAuth1, yii\authclient\OAuth2, yii\authclient\clients\Facebook, yii\authclient\clients\GitHub, yii\authclient\clients\GoogleHybrid, yii\authclient\clients\GoogleOAuth, yii\authclient\clients\LinkedIn, yii\authclient\clients\Live, yii\authclient\clients\Twitter, yii\authclient\clients\VKontakte, yii\authclient\clients\YandexOAuth
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 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\Object
__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. 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
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\Object
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
getCurlOptions() yii\authclient\BaseOAuth
getId() yii\authclient\ClientInterface
getName() yii\authclient\ClientInterface
getNormalizeUserAttributeMap() yii\authclient\BaseClient
getReturnUrl() yii\authclient\BaseOAuth
getSignatureMethod() yii\authclient\BaseOAuth
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\Object
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() yii\authclient\BaseOAuth
setCurlOptions() yii\authclient\BaseOAuth
setId() yii\authclient\ClientInterface
setName() yii\authclient\ClientInterface
setNormalizeUserAttributeMap() yii\authclient\BaseClient
setReturnUrl() yii\authclient\BaseOAuth
setSignatureMethod() yii\authclient\BaseOAuth
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
apiInternal() Performs request to the OAuth API. yii\authclient\BaseOAuth
composeRequestCurlOptions() Composes HTTP request CUrl options, which will be merged with the default ones. yii\authclient\BaseOAuth
composeUrl() Composes URL from base URL and GET params. yii\authclient\BaseOAuth
convertXmlToArray() Converts XML document to array. yii\authclient\BaseOAuth
createSignatureMethod() Creates signature method instance from its configuration. yii\authclient\BaseOAuth
createToken() Creates token from its configuration. yii\authclient\BaseOAuth
defaultCurlOptions() Returns default cURL options. yii\authclient\BaseOAuth
defaultName() Generates service name. yii\authclient\BaseClient
defaultNormalizeUserAttributeMap() Returns the default $normalizeUserAttributeMap value. yii\authclient\BaseClient
defaultReturnUrl() Composes default $returnUrl value. yii\authclient\BaseOAuth
defaultTitle() Generates service title. yii\authclient\BaseClient
defaultViewOptions() Returns the default $viewOptions value. yii\authclient\BaseClient
determineContentTypeByHeaders() Attempts to determine HTTP request content type by headers. yii\authclient\BaseOAuth
determineContentTypeByRaw() Attempts to determine the content type from raw content. yii\authclient\BaseOAuth
getState() Returns persistent state value. yii\authclient\BaseOAuth
getStateKeyPrefix() Returns session key prefix, which is used to store internal states. yii\authclient\BaseOAuth
initUserAttributes() Initializes authenticated user attributes. yii\authclient\BaseClient
mergeCurlOptions() Merge CUrl options. yii\authclient\BaseOAuth
normalizeUserAttributes() Normalize given user attributes according to $normalizeUserAttributeMap. yii\authclient\BaseClient
processResponse() Processes raw response converting it to actual data. yii\authclient\BaseOAuth
removeState() Removes persistent state value. yii\authclient\BaseOAuth
restoreAccessToken() Restores access token. yii\authclient\BaseOAuth
saveAccessToken() Saves token as persistent state. yii\authclient\BaseOAuth
sendRequest() Sends HTTP request. yii\authclient\BaseOAuth
setState() Sets persistent state. yii\authclient\BaseOAuth

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
CONTENT_TYPE_AUTO 'auto' yii\authclient\BaseOAuth
CONTENT_TYPE_JSON 'json' yii\authclient\BaseOAuth
CONTENT_TYPE_URLENCODED 'urlencoded' yii\authclient\BaseOAuth
CONTENT_TYPE_XML 'xml' yii\authclient\BaseOAuth

Property Details

$accessToken public property
$apiBaseUrl public property

API base URL.

$authUrl public property

Authorize URL.

$curlOptions public property
array getCurlOptions( )
void setCurlOptions( array $curlOptions )

CURL options.

$returnUrl public property
string getReturnUrl( )
void setReturnUrl$returnUrl )

Return URL

$scope public property
string $scope null

Auth request scope.

$signatureMethod public property

Signature method instance or its array configuration.

$version public property
string $version '1.0'

Protocol version.

Method Details

api() public method

Performs request to the OAuth API.

array api$apiSubUrl$method 'GET', array $params = [], array $headers = [] )
$apiSubUrl string

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

$method string

Request method.

$params array

Request parameters.

$headers array

Additional request headers.

return array

API response

throws yii\base\Exception

on failure.

apiInternal() protected method

Performs request to the OAuth API.

array apiInternal$accessToken$url$method, array $params, array $headers )
$accessToken yii\authclient\OAuthToken

Actual access token.

$url string

Absolute API URL.

$method string

Request method.

$params array

Request parameters.

$headers array

Additional request headers.

return array

API response.

throws yii\base\Exception

on failure.

composeRequestCurlOptions() protected method

Composes HTTP request CUrl options, which will be merged with the default ones.

array composeRequestCurlOptions$method$url, array $params )
$method string

Request type.

$url string

Request URL.

$params array

Request params.

return array

CUrl options.

throws yii\base\Exception

on failure.

composeUrl() protected method

Composes URL from base URL and GET params.

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

Base URL.

$params array

GET params.

return string

Composed URL.

convertXmlToArray() protected method

Converts XML document to array.

array convertXmlToArray$xml )
$xml string|SimpleXMLElement

Xml to process.

return array

XML array representation.

createSignatureMethod() protected method

Creates signature method instance from its configuration.

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.

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

Token configuration.

return yii\authclient\OAuthToken

Token instance.

defaultCurlOptions() protected method

Returns default cURL options.

array defaultCurlOptions( )
return array

CURL options.

defaultReturnUrl() protected method

Composes default $returnUrl value.

string defaultReturnUrl( )
return string

Return URL.

determineContentTypeByHeaders() protected method

Attempts to determine HTTP request content type by headers.

string determineContentTypeByHeaders( array $headers )
$headers array

Request headers.

return string

Content type.

determineContentTypeByRaw() protected method

Attempts to determine the content type from raw content.

string determineContentTypeByRaw$rawContent )
$rawContent string

Raw response content.

return string

Response type.

getAccessToken() public method

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

Auth token instance.

getCurlOptions() public method

array getCurlOptions( )
return array

CURL options.

getReturnUrl() public method

string getReturnUrl( )
return string

Return URL.

getSignatureMethod() public method

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

Signature method instance.

getState() protected method

Returns persistent state value.

mixed getState$key )
$key string

State key.

return mixed

State value.

getStateKeyPrefix() protected method

Returns session key prefix, which is used to store internal states.

string getStateKeyPrefix( )
return string

Session key prefix.

mergeCurlOptions() protected method

Merge CUrl options.

If each options array has an element with the same key value, the latter will overwrite the former.

array mergeCurlOptions$options1$options2 )
$options1 array

Options to be merged to.

$options2 array

Options to be merged from. You can specify additional arrays via third argument, fourth argument etc.

return array

Merged options (the original options are not changed.)

processResponse() protected method

Processes raw response converting it to actual data.

array processResponse$rawResponse$contentType self::CONTENT_TYPE_AUTO )
$rawResponse string

Raw response.

$contentType string

Response content type.

return array

Actual response.

throws yii\base\Exception

on failure.

refreshAccessToken() public method

Gets new auth token to replace expired one.

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

Expired auth token.

return yii\authclient\OAuthToken

New auth token.

removeState() protected method

Removes persistent state value.

boolean removeState$key )
$key string

State key.

return boolean

Success.

restoreAccessToken() protected method

Restores access token.

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

Auth token.

saveAccessToken() protected method

Saves token as persistent state.

static saveAccessToken( \yii\authclient\OAuthToken $token )
$token yii\authclient\OAuthToken

Auth token

return static

Self reference.

sendRequest() protected method

Sends HTTP request.

array sendRequest$method$url, array $params = [], array $headers = [] )
$method string

Request type.

$url string

Request URL.

$params array

Request params.

$headers array

Additional request headers.

return array

Response.

throws yii\base\Exception

on failure.

setAccessToken() public method

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

void setCurlOptions( array $curlOptions )
$curlOptions array

CURL options.

setReturnUrl() public method

void setReturnUrl$returnUrl )
$returnUrl string

Return URL

setSignatureMethod() public method

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

Signature method instance or its array configuration.

throws yii\base\InvalidParamException

on wrong argument.

setState() protected method

Sets persistent state.

static setState$key$value )
$key string

State key.

$value mixed

State value

return static

Self reference.