/**
* @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();
}