fetchRequestToken() публичный Метод

Fetches the OAuth request token.
public fetchRequestToken ( array $params = [] ) : OAuthToken
$params array additional request params.
Результат OAuthToken request token.
Пример #1
0
 /**
  * @return string
  * @throws Exception
  */
 public function getAuthorizationUri()
 {
     if ($this->service instanceof OAuth1) {
         $token = $this->service->fetchRequestToken();
         $authorizationUri = $this->service->buildAuthUrl($token);
     } elseif ($this->service instanceof OAuth2) {
         $authorizationUri = $this->service->buildAuthUrl();
     } else {
         throw new Exception(Yii::t('SyncSocial', 'SyncSocial is not support {serviceName}.', ['serviceName' => get_class($this->service)]));
     }
     return $authorizationUri;
 }
Пример #2
0
 /**
  * Performs OAuth1 auth flow.
  * @param OAuth1 $client auth client instance.
  * @return Response action response.
  */
 protected function authOAuth1($client)
 {
     // user denied error
     if (isset($_GET['denied'])) {
         return $this->redirectCancel();
     }
     if (isset($_REQUEST['oauth_token'])) {
         $oauthToken = $_REQUEST['oauth_token'];
     }
     if (!isset($oauthToken)) {
         // Get request token.
         $requestToken = $client->fetchRequestToken();
         // Get authorization URL.
         $url = $client->buildAuthUrl($requestToken);
         // Redirect to authorization URL.
         return Yii::$app->getResponse()->redirect($url);
     } else {
         // Upgrade to access token.
         $client->fetchAccessToken();
         return $this->authSuccess($client);
     }
 }