laravel / socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.
https://laravel.com/docs/socialite
MIT License
5.58k stars 940 forks source link

GoogleProvider Not Receiving nickname Key #690

Closed falconsmilie closed 9 months ago

falconsmilie commented 9 months ago

Socialite Version

5.12.0

Laravel Version

10.44.0

PHP Version

8.2

Database Driver & Version

No response

Description

\Laravel\Socialite\Two\GoogleProvider::getUserByToken is not getting nickname in the response.

Here's a dump of the $response->getBody()->getContents() from within \Laravel\Socialite\Two\GoogleProvider::getUserByToken.

{
  "sub": "...",
  "name": "...",
  "given_name": "...",
  "picture": "https://lh3.googleusercontent.com/a/...",
  "email": "...@google.com",
  "email_verified": true,
  "locale": "en-GB"
}

Steps To Reproduce

The implementation I've used is quite simple.

A call to: Socialite::driver('google')->redirect().

Redirects to Google. In my case: https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?...

Then assign the result of Socialite::driver('google')->user() to a local $user var.

$user->getNickname(); is always null (with the 2 different Google accounts I've tried).

github-actions[bot] commented 9 months ago

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

falconsmilie commented 9 months ago

I'm happy to create a PR, but wanted to know if this is reproducable for anyone else, and if there are any backward compat concerns I need to know about.

EDIT: After reading the Google docs, it seems this value shouldn't exist in the repsonse from Google.

The nickname portion of the setting in Google is returned concatenated to the name value in the response from Google (if that setting is enabled in the Google "how to display name" thing setting).

driesvints commented 9 months ago

Looks like we're not going to take action here for now, sorry.