Hi,
My Facebook login has stopped working now. I am using Laravel 5.3 Socialite 2.0
Checking my logs
ERROR: exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: `GET https://graph.facebook.com/v2.6/me?access_token=&fields=name,email,gender,verified&appsecret_proof=4bdbc6f9cfccf8bf9029242a322b63f395ce8965a98d453832356078ca1acf54` resulted in a `400 Bad Request` response:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthExce (truncated...)
' in /...../vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111
Stack trace:
#0 /..../vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
After some research I found that i need to add redirect URL inside my Facebook app. When loggin into FB developers, (there was a warning about the new policy change and about adding redirect URL to the settings)
I added my redirect URL to Valid OAuth redirect URIs. After this I anm able to see the login page, but login fails. Checked the logs and still seeing same error. Any pointers please?
You need to update Socialite v2.0.21. Just change your composer.json
"laravel/socialite": "2.*"
and run
composer update
The new version has changes to FacebookProvider.php
protected function getTokenUrl()
{
// return $this->graphUrl.'/oauth/access_token';
return $this->graphUrl.'/'.$this->version.'/oauth/access_token';
}
public function getAccessTokenResponse($code)
$postKey => $this->getTokenFields($code),
]);
$data = [];
//parse_str($response->getBody(), $data);
$data = json_decode($response->getBody(), true);
return Arr::add($data, 'expires_in', Arr::pull($data, 'expires'));
}