Я использую логин Google authclient в своем приложении. Логин Google работает отлично, но я не могу получить атрибуты пользователя.
web.php
'google' => [
'class' => 'yii\authclient\clients\GoogleOAuth',
'clientId' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'clientSecret' => 'xxxxxxxxxxxxxxxxxxxxxxxx',
'scope'=>' https://www.googleapis.com/auth/plus.profile.emails.read',
'returnUrl'=>'https://localhost/mysite',
],
sitecontroller.php
public function actions()
{
return [
'auth' => [
'class' =>'yii\authclient\AuthAction',
'successCallback' => [
$this, 'successCallback'
],
],
];
}
успешный обратный вызов()
public function successCallback($client)
{
$attributes = $client->getUserAttributes();
// print_r($attributes);die();
// user login or signup comes here
// print_r($attributes['email']);die();
$user_email = $attributes['email'];
$user_name = $attributes['name'];
// echo $user_email;echo '<br>';
// echo $user_name;
// die();
$user = User::find()->where(['user_email'=>$user_email])->one();
$count = count($user);
if ($count == 0 ){
return $this->redirect(['user/create?email='.$user_email.'&name='.$user_name.'']);
}else{
return Yii::$app->user->login($user);
//echo Yii::$app->user->identity->id;die();
}
Может ли кто-нибудь помочь мне в этом..
Спасибо..