N
N
Nik2019-01-19 12:53:51
Laravel
Nik, 2019-01-19 12:53:51

How to pull VK email using socialite laravel?

$userSocial = Socialite::driver('vkontakte')->user();
$user = new User;
$user->name = $userSocial->name;
$user->email = $userSocial->email;
$user->save();
I'm trying to do so.
According to the documentation I don't understand anything https://github.com/SocialiteProviders/VKontakte/bl...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Arutyunov, 2019-01-19
@racer888

You need to look at the answer from VK, I have the following handler:

public static function getUserEmail($user, $provider)
{
    if($provider == 'vkontakte') {
        return $user->accessTokenResponseBody['email'] ?? null;
    }
    return $user->email;
}

I wrote a note about this problem in more detail .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question