Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkedin Oauth fails of user is missing a profile picture #328

Closed
aoatridge opened this issue Jan 19, 2019 · 5 comments
Closed

Linkedin Oauth fails of user is missing a profile picture #328

aoatridge opened this issue Jan 19, 2019 · 5 comments
Labels

Comments

@aoatridge
Copy link

Using
"laravel/socialite": "^4.0"

I get a "array_filter() expects parameter 1 to be array, null given" when it tries to run mapUserToObject() in socialite/src/Two/LinkedInProvider.php.

My test account is missing an avatar image.
var_dump of the $user object passed to it.

array (size=4)
  'firstName' => 
    array (size=2)
      'localized' => 
        array (size=1)
          'en_US' => string 'Mark' (length=4)
      'preferredLocale' => 
        array (size=2)
          'country' => string 'US' (length=2)
          'language' => string 'en' (length=2)
  'lastName' => 
    array (size=2)
      'localized' => 
        array (size=1)
          'en_US' => string 'Smith' (length=8)
      'preferredLocale' => 
        array (size=2)
          'country' => string 'US' (length=2)
          'language' => string 'en' (length=2)
  'id' => string 'BhcxETf1d3' (length=10)
  'emailAddress' => string '[email protected]' (length=24)
@aoatridge
Copy link
Author

Confirmed that it works with a linkedin account that has an avatar pic.

@driesvints driesvints added the bug label Jan 21, 2019
@tosty33
Copy link
Contributor

tosty33 commented Jan 21, 2019

I'm experiencing a similar problem, but in my case even this code doesn't work:
Socialite::driver('linkedin')->user()

I'm getting the error:
array_filter() expects parameter 1 to be array, null given

And it happens there:

$user = $this->mapUserToObject($this->getUserByToken(
            $token = Arr::get($response, 'access_token')
        ));

socialite/src/Two/AbstractProvider.php, user function, line 216

@driesvints
Copy link
Member

@Crypton33 probably the same error. And it can't have happened on that line because there's no array_filter call there. It's probably happening inside the mapUserToObject call.

@driesvints
Copy link
Member

Released 4.0.2 with a bugfix for this. Can you try again?

@tosty33
Copy link
Contributor

tosty33 commented Jan 21, 2019

Works fine now, thanks 👍

drakeford97 added a commit to drakeford97/Socialite that referenced this issue May 25, 2022
When a person hasn't got an image set for their account its images won't be returned as an array. We'll now default to an empty array.

Fixes laravel/socialite#328
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants