Skip to content

Commit

Permalink
Merge pull request #346 from driesvints/update-google-provider
Browse files Browse the repository at this point in the history
[4.0] Update Google API urls
  • Loading branch information
taylorotwell authored Feb 22, 2019
2 parents 7581c57 + 1c07731 commit 464af93
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Two/GoogleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function getAuthUrl($state)
*/
protected function getTokenUrl()
{
return 'https://accounts.google.com/o/oauth2/token';
return 'https://www.googleapis.com/oauth2/v4/token';
}

/**
Expand All @@ -58,7 +58,7 @@ protected function getTokenFields($code)
*/
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get('https://www.googleapis.com/userinfo/v2/me?', [
$response = $this->getHttpClient()->get('https://www.googleapis.com/oauth2/v3/userinfo', [
'query' => [
'prettyPrint' => 'false',
],
Expand All @@ -76,15 +76,18 @@ protected function getUserByToken($token)
*/
protected function mapUserToObject(array $user)
{
$avatarUrl = Arr::get($user, 'picture');
// Deprecated: Fields added to keep backwards compatibility in 4.0. These will be removed in 5.0
$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' => $user['id'],
'id' => Arr::get($user, 'sub'),
'nickname' => Arr::get($user, 'nickname'),
'name' => Arr::get($user, 'name'),
'email' => Arr::get($user, 'email'),
'avatar' => $avatarUrl,
'avatar_original' => preg_replace('/\?sz=([0-9]+)/', '', $avatarUrl),
'avatar' => $avatarUrl = Arr::get($user, 'picture'),
'original_avatar' => $avatarUrl,
]);
}
}

0 comments on commit 464af93

Please sign in to comment.