buildAuthUrl() public method

Composes user authorization URL.
public buildAuthUrl ( array $params = [] ) : string
$params array additional auth GET params.
return string authorization URL.
 public function testBuildAuthUrl()
 {
     $oauthClient = new OAuth2();
     $authUrl = 'http://test.auth.url';
     $oauthClient->authUrl = $authUrl;
     $clientId = 'test_client_id';
     $oauthClient->clientId = $clientId;
     $returnUrl = 'http://test.return.url';
     $oauthClient->setReturnUrl($returnUrl);
     $builtAuthUrl = $oauthClient->buildAuthUrl();
     $this->assertContains($authUrl, $builtAuthUrl, 'No auth URL present!');
     $this->assertContains($clientId, $builtAuthUrl, 'No client id present!');
     $this->assertContains(rawurlencode($returnUrl), $builtAuthUrl, 'No return URL present!');
 }
Example #2
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;
 }
 public function buildAuthUrl(array $params = [])
 {
     $authState = $this->generateAuthState();
     $this->setState('authState', $authState);
     $params['state'] = $authState;
     return parent::buildAuthUrl($params);
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function buildAuthUrl(array $params = [])
 {
     $claims = ['userInfo' => ['projectGroups' => ['essential' => true], 'exInfo' => ['essential' => true]]];
     $params['claims'] = Json::encode($claims);
     $params['contextData'] = $this->contextData;
     $uiLocales = Yii::$app->getRequest()->get("ui_locales");
     $params['ui_locales'] = $uiLocales ? $uiLocales : Yii::$app->language;
     return parent::buildAuthUrl($params);
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function buildAuthUrl(array $params = [])
 {
     return parent::buildAuthUrl(array_merge(['state' => 'ignored'], $params));
 }