Для авторизации через Google использую виджет yii\authclient\widgets\AuthChoice::widget
Для авторизации по ответу от гугла используется экшн
Код: Выделить всё
public function onAuthSuccess(ClientInterface $client) //: void
{
$network = $client->getId();
$attributes = $client->getUserAttributes();
$identity = ArrayHelper::getValue($attributes, 'id');
$email = $attributes['email'] ?? null;
try {
$user = $this->networkService->auth($network, $identity, $email);
\Yii::$app->user->login($user, \Yii::$app->params['user.rememberMeDuration']);
} catch (\DomainException $e) {
\Yii::$app->errorHandler->logException($e);
\Yii::$app->session->setFlash('error', $e->getMessage());
}
}