I am using Laravel's Socialite package (version 2.0.0). It is working great for google and github but when I try to login with facebook, I get this:
ErrorException in FacebookProvider.php line 89:
Undefined index: first_name
In the FacebookProvider.php
the error is from this method:
protected function mapUserToObject(array $user)
{
return (new User)->setRaw($user)->map([
'id' => $user['id'], 'nickname' => null, 'name' => $user['first_name'].' '.$user['last_name'],
'email' => isset($user['email']) ? $user['email'] : null, 'avatar' => $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture?type=normal',
]);
}
If I dd()
the $user
param before this mapping. I only get id and the name of the authenticated Facebook user. So, it means that I am not getting the email of the Facebook user. I at least need name
and email
of the user.
After dd()
this method looks like this:
protected function mapUserToObject(array $user)
{
dd($user);
return (new User)->setRaw($user)->map([
'id' => $user['id'], 'nickname' => null, 'name' => $user['first_name'].' '.$user['last_name'],
'email' => isset($user['email']) ? $user['email'] : null, 'avatar' => $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture?type=normal',
]);
}
What could be the problem? Please help me.
I have the same problem and is a bug! use the new version of file FacebookProvider.php here and work!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With