Abstract Class yii\authclient\BaseOAuth
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 |
$parametersToKeepInReturnUrl | array | List of the parameters to keep in default return url. | 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 |
---|---|---|
composeUrl() | Composes URL from base URL and GET params. | yii\authclient\BaseOAuth |
createHttpClient() | {@inheritdoc} | yii\authclient\BaseOAuth |
createSignatureMethod() | Creates signature method instance from its configuration. | yii\authclient\BaseOAuth |
createToken() | Creates token from its configuration. | yii\authclient\BaseOAuth |
defaultName() | Generates service name. | yii\authclient\BaseClient |
defaultNormalizeUserAttributeMap() | Returns the default \yii\authclient\normalizeUserAttributeMap value. | yii\authclient\BaseClient |
defaultRequestOptions() | {@inheritdoc} | yii\authclient\BaseOAuth |
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 |
getState() | Returns persistent state value. | yii\authclient\BaseClient |
getStateKeyPrefix() | Returns session key prefix, which is used to store internal states. | yii\authclient\BaseClient |
initUserAttributes() | Initializes authenticated user attributes. | yii\authclient\BaseClient |
normalizeUserAttributes() | Normalize given user attributes according to \yii\authclient\normalizeUserAttributeMap. | yii\authclient\BaseClient |
removeState() | Removes persistent state value. | yii\authclient\BaseClient |
restoreAccessToken() | Restores access token. | yii\authclient\BaseOAuth |
saveAccessToken() | Saves token as persistent state. | yii\authclient\BaseOAuth |
sendRequest() | Sends the given HTTP request, returning response data. | yii\authclient\BaseOAuth |
setState() | Sets persistent state. | yii\authclient\BaseClient |
Property Details
API base URL. This field will be used as \yii\httpclient\Client::baseUrl value of \yii\authclient\httpClient. Note: changing this property will take no effect after \yii\authclient\httpClient is instantiated.
Authorize URL.
Whether to automatically perform 'refresh access token' request on expired access token.
List of the parameters to keep in default return url.
Auth request scope.
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 \yii\authclient\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. |
---|
{@inheritdoc}
protected void createHttpClient ( $reference ) | ||
$reference |
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. |
---|
{@inheritdoc}
protected void defaultRequestOptions ( ) |
Composes default \yii\authclient\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|null | Access token or its configuration. Set to null to restore token from token store. |
{@inheritdoc}
public void setHttpClient ( $httpClient ) | ||
$httpClient |
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\InvalidArgumentException | on wrong argument. |
---|