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
Property Details
Access token or its configuration.
API base URL. This field will be used as yii\httpclient\Client::$baseUrl value of $httpClient. Note: changing this property will take no effect after $httpClient is instantiated.
Authorize URL.
Whether to automatically perform 'refresh access token' request on expired access token.
Return URL
Auth request scope.
Signature method instance or its array configuration.
public void setSignatureMethod ( $signatureMethod )
Protocol version.
Method Details
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. |
---|
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. |
Handles yii\httpclient\Request::EVENT_BEFORE_SEND event.
Applies $accessToken to the request.
public void beforeApiRequestSend ( $event ) | ||
$event | yii\httpclient\RequestEvent | Event instance. |
throws | yii\base\Exception | on invalid access token. |
---|
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. |
---|
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. |
---|
Creates HTTP client instance from reference or configuration.
protected yii\httpclient\Client createHttpClient ( $reference ) | ||
$reference | string|array | Component name or array configuration. |
return | yii\httpclient\Client | HTTP client instance. |
---|
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 HTTP request options.
protected array defaultRequestOptions ( ) | ||
return | array | HTTP request options. |
---|
Composes default $returnUrl value.
protected string defaultReturnUrl ( ) | ||
return | string | Return URL. |
---|
public yii\authclient\OAuthToken getAccessToken ( ) | ||
return | yii\authclient\OAuthToken | Auth token instance. |
---|
public string getReturnUrl ( ) | ||
return | string | Return URL. |
---|
public yii\authclient\signature\BaseMethod getSignatureMethod ( ) | ||
return | yii\authclient\signature\BaseMethod | Signature method instance. |
---|
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. |
---|
Restores access token.
protected yii\authclient\OAuthToken restoreAccessToken ( ) | ||
return | yii\authclient\OAuthToken | Auth token. |
---|
Saves token as persistent state.
protected $this saveAccessToken ( $token ) | ||
$token | yii\authclient\OAuthToken|null | Auth token to be saved. |
return | $this | The object itself. |
---|
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. |
Sets access token to be used.
public void setAccessToken ( $token ) | ||
$token | array|yii\authclient\OAuthToken | Access token or its configuration. |
Sets HTTP client to be used.
public void setHttpClient ( $httpClient ) | ||
$httpClient | array|yii\httpclient\Client | Internal HTTP client. |
public void setReturnUrl ( $returnUrl ) | ||
$returnUrl | string | Return URL |
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\InvalidParamException | on wrong argument. |
---|