Abstract Class yii\authclient\BaseOAuth
Inheritance | yii\authclient\BaseOAuth » yii\authclient\BaseClient » yii\base\Component |
---|---|
Implements | yii\authclient\ClientInterface |
Subclasses | yii\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 version | 2.0 |
BaseOAuth is a base class for the OAuth clients.
See also http://oauth.net/.
Public Properties
Property | Type | Description | Defined 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 |
Public Methods
Protected Methods
Method | Description | Defined 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
Constant | Value | Description | Defined 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
API base URL.
Authorize URL.
Whether to automatically perform 'refresh access token' request on expired access token.
Auth request scope.
Protocol version.
Method Details
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. |
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. |
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. |
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. |
---|
Converts XML document to array.
protected array convertXmlToArray ( $xml ) | ||
$xml | string|SimpleXMLElement | Xml to process. |
return | array | XML array representation. |
---|
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. |
---|
Creates token from its configuration.
protected yii\authclient\OAuthToken createToken ( array $tokenConfig = [] ) | ||
$tokenConfig | array | Token configuration. |
return | yii\authclient\OAuthToken | Token instance. |
---|
Returns default cURL options.
protected array defaultCurlOptions ( ) | ||
return | array | CURL options. |
---|
Composes default \yii\authclient\returnUrl value.
protected string defaultReturnUrl ( ) | ||
return | string | Return URL. |
---|
Attempts to determine HTTP request content type by headers.
protected string determineContentTypeByHeaders ( array $headers ) | ||
$headers | array | Request headers. |
return | string | Content type. |
---|
Attempts to determine the content type from raw content.
protected string determineContentTypeByRaw ( $rawContent ) | ||
$rawContent | string | Raw response content. |
return | string | Response type. |
---|
public yii\authclient\OAuthToken getAccessToken ( ) | ||
return | yii\authclient\OAuthToken | Auth token instance. |
---|
public array getCurlOptions ( ) | ||
return | array | CURL options. |
---|
public string getReturnUrl ( ) | ||
return | string | Return URL. |
---|
public yii\authclient\signature\BaseMethod getSignatureMethod ( ) | ||
return | yii\authclient\signature\BaseMethod | Signature method instance. |
---|
Returns persistent state value.
protected mixed getState ( $key ) | ||
$key | string | State key. |
return | mixed | State value. |
---|
Returns session key prefix, which is used to store internal states.
protected string getStateKeyPrefix ( ) | ||
return | string | Session key prefix. |
---|
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.) |
---|
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. |
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. |
---|
Removes persistent state value.
protected boolean removeState ( $key ) | ||
$key | string | State key. |
return | boolean | Success. |
---|
Restores access token.
protected yii\authclient\OAuthToken restoreAccessToken ( ) | ||
return | yii\authclient\OAuthToken | Auth token. |
---|
Saves token as persistent state.
protected $this saveAccessToken ( yii\authclient\OAuthToken $token ) | ||
$token | yii\authclient\OAuthToken | Auth token |
return | $this | The object itself. |
---|
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. |
public void setAccessToken ( $token ) | ||
$token | array|yii\authclient\OAuthToken |
public void setCurlOptions ( array $curlOptions ) | ||
$curlOptions | array | CURL options. |
public void setReturnUrl ( $returnUrl ) | ||
$returnUrl | string | Return URL |
public void setSignatureMethod ( $signatureMethod ) | ||
$signatureMethod | array|yii\authclient\signature\BaseMethod | Signature method instance or its array configuration. |
throws | \yii\base\InvalidParamException | on wrong argument. |
---|
Sets persistent state.
protected $this setState ( $key, $value ) | ||
$key | string | State key. |
$value | mixed | State value |
return | $this | The object itself |
---|