Class yii\authclient\OAuth1
Inheritance | yii\authclient\OAuth1 » yii\authclient\BaseOAuth » yii\authclient\BaseClient » yii\base\Component |
---|---|
Implements | yii\authclient\ClientInterface |
Subclasses | yii\authclient\clients\Twitter |
Available since version | 2.0 |
OAuth1 serves as a client for the OAuth 1/1.0a flow.
In order to acquire access token perform following sequence:
use yii\authclient\OAuth1;
$oauthClient = new OAuth1();
$requestToken = $oauthClient->fetchRequestToken(); // Get request token
$url = $oauthClient->buildAuthUrl($requestToken); // Get authorization URL
return Yii::$app->getResponse()->redirect($url); // Redirect to authorization URL
// After user returns at our site:
$accessToken = $oauthClient->fetchAccessToken($requestToken); // Upgrade to access token
See also http://oauth.net/.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$accessTokenMethod | string | Access token HTTP method. | yii\authclient\OAuth1 |
$accessTokenUrl | string | OAuth access token URL. | yii\authclient\OAuth1 |
$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 |
$consumerKey | string | OAuth consumer key. | yii\authclient\OAuth1 |
$consumerSecret | string | OAuth consumer secret. | yii\authclient\OAuth1 |
$requestTokenMethod | string | Request token HTTP method. | yii\authclient\OAuth1 |
$requestTokenUrl | string | OAuth request token URL. | yii\authclient\OAuth1 |
$scope | string | Auth request scope. | yii\authclient\BaseOAuth |
$version | string | Protocol version. | yii\authclient\OAuth1 |
Public Methods
Protected Methods
Method | Description | Defined By |
---|---|---|
apiInternal() | Performs request to the OAuth API. | yii\authclient\OAuth1 |
composeAuthorizationHeader() | Composes authorization header content. | yii\authclient\OAuth1 |
composeRequestCurlOptions() | Composes HTTP request CUrl options, which will be merged with the default ones. | yii\authclient\OAuth1 |
composeSignatureBaseString() | Creates signature base string, which will be signed by \yii\authclient\signatureMethod. | yii\authclient\OAuth1 |
composeSignatureKey() | Composes request signature key. | yii\authclient\OAuth1 |
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\OAuth1 |
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 |
generateCommonRequestParams() | Generate common request params like version, timestamp etc. | yii\authclient\OAuth1 |
generateNonce() | Generates nonce value. | yii\authclient\OAuth1 |
generateTimestamp() | Generates timestamp. | yii\authclient\OAuth1 |
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 |
sendSignedRequest() | Sends HTTP request, signed by \yii\authclient\signatureMethod. | yii\authclient\OAuth1 |
setState() | Sets persistent state. | yii\authclient\BaseOAuth |
signRequest() | Sign request with \yii\authclient\signatureMethod. | yii\authclient\OAuth1 |
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
Access token HTTP method.
OAuth access token URL.
OAuth consumer key.
OAuth consumer secret.
Request token HTTP method.
OAuth request token URL.
Protocol version.
Method Details
Performs request to the OAuth API.
protected 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 user authorization URL.
public string buildAuthUrl ( yii\authclient\OAuthToken $requestToken = null, array $params = [] ) | ||
$requestToken | yii\authclient\OAuthToken | OAuth request token. |
$params | array | Additional request params. |
return | string | Authorize URL |
---|---|---|
throws | \yii\base\Exception | on failure. |
Composes authorization header content.
protected string composeAuthorizationHeader ( array $params, $realm = '' ) | ||
$params | array | Request params. |
$realm | string | Authorization realm. |
return | string | Authorization header content. |
---|
Composes HTTP request CUrl options, which will be merged with the default ones.
protected 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. |
Creates signature base string, which will be signed by \yii\authclient\signatureMethod.
protected string composeSignatureBaseString ( $method, $url, array $params ) | ||
$method | string | Request method. |
$url | string | Request URL. |
$params | array | Request params. |
return | string | Base signature string. |
---|
Composes request signature key.
protected string composeSignatureKey ( ) | ||
return | string | Signature key. |
---|
Composes default \yii\authclient\returnUrl value.
protected string defaultReturnUrl ( ) | ||
return | string | Return URL. |
---|
Fetches OAuth access token.
public yii\authclient\OAuthToken fetchAccessToken ( yii\authclient\OAuthToken $requestToken = null, $oauthVerifier = null, array $params = [] ) | ||
$requestToken | yii\authclient\OAuthToken | OAuth request token. |
$oauthVerifier | string | OAuth verifier. |
$params | array | Additional request params. |
return | yii\authclient\OAuthToken | OAuth access token. |
---|---|---|
throws | \yii\base\Exception | on failure. |
Fetches the OAuth request token.
public yii\authclient\OAuthToken fetchRequestToken ( array $params = [] ) | ||
$params | array | Additional request params. |
return | yii\authclient\OAuthToken | Request token. |
---|
Generate common request params like version, timestamp etc.
protected array generateCommonRequestParams ( ) | ||
return | array | Common request params. |
---|
Generates nonce value.
protected string generateNonce ( ) | ||
return | string | Nonce value. |
---|
Generates timestamp.
protected integer generateTimestamp ( ) | ||
return | integer | Timestamp. |
---|
Gets new auth token to replace expired one.
public yii\authclient\OAuthToken refreshAccessToken ( yii\authclient\OAuthToken $token ) | ||
$token | yii\authclient\OAuthToken | Expired auth token. |
return | yii\authclient\OAuthToken | New auth token. |
---|
Sends HTTP request, signed by \yii\authclient\signatureMethod.
protected array sendSignedRequest ( $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. |
---|
Sign request with \yii\authclient\signatureMethod.
protected array signRequest ( $method, $url, array $params ) | ||
$method | string | Request method. |
$url | string | Request URL. |
$params | array | Request params. |
return | array | Signed request params. |
---|