Abstract Class yii\authclient\BaseOAuth
BaseOAuth is a base class for the OAuth clients.
See also http://oauth.net/.
Public Properties
Public Methods
Protected Methods
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.
CURL options.
Return URL
Auth request scope.
void setSignatureMethod( $signatureMethod )
Signature method instance or its array configuration.
Protocol version.
Method Details
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. |
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. |
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. |
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. |
|---|---|---|
Converts XML document to array.
| array convertXmlToArray( $xml ) | ||
| $xml | string|SimpleXMLElement | Xml to process. |
| return | array | XML array representation. |
|---|---|---|
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. |
|---|---|---|
Creates token from its configuration.
| yii\authclient\OAuthToken createToken( array $tokenConfig = [] ) | ||
| $tokenConfig | array | Token configuration. |
| return | yii\authclient\OAuthToken | Token instance. |
|---|---|---|
Returns default cURL options.
| array defaultCurlOptions( ) | ||
| return | array | CURL options. |
|---|---|---|
Composes default $returnUrl value.
| string defaultReturnUrl( ) | ||
| return | string | Return URL. |
|---|---|---|
Attempts to determine HTTP request content type by headers.
| string determineContentTypeByHeaders( array $headers ) | ||
| $headers | array | Request headers. |
| return | string | Content type. |
|---|---|---|
Attempts to determine the content type from raw content.
| string determineContentTypeByRaw( $rawContent ) | ||
| $rawContent | string | Raw response content. |
| return | string | Response type. |
|---|---|---|
| yii\authclient\OAuthToken getAccessToken( ) | ||
| return | yii\authclient\OAuthToken | Auth token instance. |
|---|---|---|
| array getCurlOptions( ) | ||
| return | array | CURL options. |
|---|---|---|
| string getReturnUrl( ) | ||
| return | string | Return URL. |
|---|---|---|
| yii\authclient\signature\BaseMethod getSignatureMethod( ) | ||
| return | yii\authclient\signature\BaseMethod | Signature method instance. |
|---|---|---|
Returns persistent state value.
| mixed getState( $key ) | ||
| $key | string | State key. |
| return | mixed | State value. |
|---|---|---|
Returns session key prefix, which is used to store internal states.
| 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.
| 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.
| 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.
| 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.
| boolean removeState( $key ) | ||
| $key | string | State key. |
| return | boolean | Success. |
|---|---|---|
Restores access token.
| yii\authclient\OAuthToken restoreAccessToken( ) | ||
| return | yii\authclient\OAuthToken | Auth token. |
|---|---|---|
Saves token as persistent state.
| static saveAccessToken( \yii\authclient\OAuthToken $token ) | ||
| $token | yii\authclient\OAuthToken | Auth token |
| return | static | Self reference. |
|---|---|---|
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. |
| void setAccessToken( $token ) | ||
| $token | array|yii\authclient\OAuthToken | |
| void setCurlOptions( array $curlOptions ) | ||
| $curlOptions | array | CURL options. |
| void setReturnUrl( $returnUrl ) | ||
| $returnUrl | string | Return URL |
| 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.
| static setState( $key, $value ) | ||
| $key | string | State key. |
| $value | mixed | State value |
| return | static | Self reference. |
|---|---|---|