I have used Laravel 5.4 with socialite 3.0 for social login on my web application. But nowadays I got an error Legacy People API has not been used in project xxx. Then I have made some changes in a core file of socialite package. /vendor/laravel/socialite/src/Two/GoogleProvider.php Line 61: Replace https://www.googleapis.com/plus/v1/people/me? by https://www.googleapis.com/oauth2/v3/userinfo?
And update mapUserToObject function with below code:
protected function mapUserToObject(array $user)
{
$user['id'] = Arr::get($user, 'sub');
$user['verified_email'] = Arr::get($user, 'email_verified');
$user['link'] = Arr::get($user, 'profile');
return (new User)->setRaw($user)->map([
'id' => Arr::get($user, 'sub'),
'nickname' => Arr::get($user, 'nickname'),
'name' => Arr::get($user, 'name'),
'email' => Arr::get($user, 'email'),
'avatar' => $avatarUrl = Arr::get($user, 'picture'),
'avatar_original' => $avatarUrl,
]);
}
Replace
https://www.googleapis.com/plus/v1/people/me?
url withhttps://www.googleapis.com/oauth2/v3/userinfo?
Google has update the API Endpoint & it recommend to use this
https://www.googleapis.com/oauth2/v3/userinfo?
endpoint to get the user details.https://developers.google.com/people/legacy
This Solution does work. Fixed my issue.
Thanks a lot.
Here is the whole file if anybody is having this issue. Just change GoogleProvider class located in: ./vendor/laravel/socialite/src/Two/GoogleProvider.php with this:
}