Abstract Class yii\authclient\BaseOAuth

Inheritanceyii\authclient\BaseOAuth » yii\authclient\BaseClient » yii\base\Component
Implementsyii\authclient\ClientInterface
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

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
$scope string Auth request scope. yii\authclient\BaseOAuth
$version string Protocol version. yii\authclient\BaseOAuth

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 \yii\authclient\normalizeUserAttributeMap value. yii\authclient\BaseClient
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
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 \yii\authclient\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

$apiBaseUrl public property

API base URL.

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.

$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.

public 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 abstract method

Performs request to the OAuth API.

protected abstract 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 abstract method

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

protected abstract 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.

protected 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.

protected array convertXmlToArray ( $xml )
$xml string|SimpleXMLElement

Xml to process.

return array

XML array representation.

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.

defaultCurlOptions() protected method

Returns default cURL options.

protected array defaultCurlOptions ( )
return array

CURL options.

defaultReturnUrl() protected method

Composes default \yii\authclient\returnUrl value.

protected string defaultReturnUrl ( )
return string

Return URL.

determineContentTypeByHeaders() protected method

Attempts to determine HTTP request content type by headers.

protected string determineContentTypeByHeaders ( array $headers )
$headers array

Request headers.

return string

Content type.

determineContentTypeByRaw() protected method

Attempts to determine the content type from raw content.

protected string determineContentTypeByRaw ( $rawContent )
$rawContent string

Raw response content.

return string

Response type.

getAccessToken() public method

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

Auth token instance.

getCurlOptions() public method

public array getCurlOptions ( )
return array

CURL options.

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.

getState() protected method

Returns persistent state value.

protected 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.

protected 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.

protected 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.

protected 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 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.

removeState() protected method

Removes persistent state value.

protected boolean removeState ( $key )
$key string

State key.

return boolean

Success.

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 ( yii\authclient\OAuthToken $token )
$token yii\authclient\OAuthToken

Auth token

return $this

The object itself.

sendRequest() protected method

Sends HTTP request.

protected 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

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

public void setCurlOptions ( array $curlOptions )
$curlOptions array

CURL options.

setReturnUrl() public method

public void setReturnUrl ( $returnUrl )
$returnUrl string

Return URL

setSignatureMethod() public method

public 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.

protected $this setState ( $key, $value )
$key string

State key.

$value mixed

State value

return $this

The object itself