yii\authclient\AuthAction::run PHP Method

run() public method

Runs the action.
public run ( )
    public function run()
    {
        if (!empty($_GET[$this->clientIdGetParamName])) {
            $clientId = $_GET[$this->clientIdGetParamName];
            /* @var $collection \yii\authclient\Collection */
            $collection = Yii::$app->get($this->clientCollection);
            if (!$collection->hasClient($clientId)) {
                throw new NotFoundHttpException("Unknown auth client '{$clientId}'");
            }
            $client = $collection->getClient($clientId);
            return $this->auth($client);
        }
        throw new NotFoundHttpException();
    }

Usage Example

 /**
  * @inheritdoc
  */
 public function run()
 {
     if (!empty($_GET['contextData'])) {
         $contextData = Json::decode($_GET['contextData']);
         if (!empty($contextData[$this->clientIdGetParamName])) {
             $clientId = $contextData[$this->clientIdGetParamName];
             /* @var $collection \yii\authclient\Collection */
             $collection = Yii::$app->get($this->clientCollection);
             if (!$collection->hasClient($clientId)) {
                 throw new UnauthorizedHttpException("Unknown auth client '{$clientId}'");
             }
             /** @var OAuth2 $client */
             $client = $collection->getClient($clientId);
             $client->contextData = Json::encode($contextData);
             if (!empty($_GET['sid'])) {
                 $client->sessionId = $_GET['sid'];
             }
             try {
                 return $this->auth($client);
             } catch (\Exception $e) {
                 throw new UnauthorizedHttpException($e->getMessage(), $e->getCode(), $e->getPrevious());
             }
         }
     }
     return parent::run();
 }
All Usage Examples Of yii\authclient\AuthAction::run