On this page
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
$accessToken public property
Access token or its configuration.
public yii\authclient\OAuthToken getAccessToken ( )
public void setAccessToken ( $token )
$apiBaseUrl public property
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.
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.
public boolean $autoRefreshAccessToken = true
$returnUrl public property
Return URL
public string getReturnUrl ( )
public void setReturnUrl ( $returnUrl )
$scope public property
Auth request scope.
public string $scope = null
$signatureMethod public property
Signature method instance or its array configuration.
public yii\authclient\signature\BaseMethod getSignatureMethod ( )
public void setSignatureMethod ( $signatureMethod )
$version public property
Protocol version.
public string $version = '1.0'
Method Details
api() public method
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. |
applyAccessTokenToRequest() public abstract method (available since version 2.1)
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. |
beforeApiRequestSend() public method (available since version 2.1)
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. |
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. |
createApiRequest() public method (available since version 2.1)
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. |
createHttpClient() protected method
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. |
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. |
defaultRequestOptions() protected method
Returns default HTTP request options.
protected array defaultRequestOptions ( ) | ||
---|---|---|
return | array | HTTP request options. |
defaultReturnUrl() protected method
Composes default $returnUrl value.
protected string defaultReturnUrl ( ) | ||
---|---|---|
return | string | Return URL. |
getAccessToken() public method
public yii\authclient\OAuthToken getAccessToken ( ) | ||
---|---|---|
return | yii\authclient\OAuthToken | Auth token instance. |
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. |
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. |
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 ( $token ) | ||
---|---|---|
$token | yii\authclient\OAuthToken|null | Auth token to be saved. |
return | $this | The object itself. |
sendRequest() protected method (available since version 2.1)
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. |
setAccessToken() public method
Sets access token to be used.
public void setAccessToken ( $token ) | ||
---|---|---|
$token | array|yii\authclient\OAuthToken | Access token or its configuration. |
setHttpClient() public method
Sets HTTP client to be used.
public void setHttpClient ( $httpClient ) | ||
---|---|---|
$httpClient | array|yii\httpclient\Client | Internal HTTP client. |
setReturnUrl() public method
public void setReturnUrl ( $returnUrl ) | ||
---|---|---|
$returnUrl | string | Return URL |
setSignatureMethod() public method
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. |
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-authclient-baseoauth.html