@everdaniel Have you figured out any solution? Here, I posted what I did on StackOverflow: http://stackoverflow.com/questions/31553530/laravel-5-1-facebook-authentication-through-socialite/
Socialite Facebook Client error: 400
Hi everyone,
I'm trying to implement Facebook login using Socialite, was able to get the Google login working but for some reason, I keep getting a Client error: 400 when trying to login with Facebook.
So far, this is what I did:
- Updated all packages via
composer update(just in case) - Laravel version is 5.1.4
- Socialite version is 2.0.7
- guzzlehttp/guzzle version is 6.0.1
on my config/services.php file I have the following:
'facebook' => [
'client_id' => env('FACEBOOK_APP_ID'),
'client_secret' => env('FACEBOOK_APP_SECRET'),
'redirect' => env('FACEBOOK_REDIRECT')
],
on my .env file, I have the following:
FACEBOOK_APP_ID=(the App ID under Settings > Basic > App ID)
FACEBOOK_APP_SECRET=(the App ID under Settings > Basic > App Secret -- the one you need to enter your password to see it --)
FACEBOOK_REDIRECT=http://app.192.168.10.10.xip.io/facebook/callback
my routes files looks like this:
Route::group(['as' => 'auth::'], function() {
Route::get('facebook/login', ['as' => 'facebook-login', 'uses' => 'Auth\AuthController@redirectToFacebook']);
Route::get('facebook/callback', ['as' => 'facebook-callback', 'uses' => 'Auth\AuthController@handleFacebookCallback']);
Route::get('facebook/deauthorize', ['as' => 'facebook-deauthorize', 'uses' => 'Auth\AuthController@handleFacebookCallback']);
Route::get('google/login', ['as' => 'google-login', 'uses' => 'Auth\AuthController@redirectToGoogle']);
Route::get('google/callback', ['as' => 'google-callback', 'uses' => 'Auth\AuthController@handleGoogleCallback']);
});
and on my AuthController, redirectToFacebook and handleFacebookCallback methods:
public function redirectToFacebook()
{
return Socialite::driver('facebook')->redirect();
}
public function handleFacebookCallback()
{
dd(Socialite::driver('facebook')->user());
}
after digging in the guzzle files, I was able to get the actual error I'm getting from Facebook which is: OAuth "Facebook Platform" "invalid_code" "This authorization code has been used.", however, I have no idea what this means?
Is there anything obvious I'm missing here?
I also double checked my app config on Facebook, I added the callback url in Settings > Advanced > Valid OAuth redirect URIs which is set to the same url defined on my .env file. My app is set as a Test App and the "parent" app is already set to Live.
Saw a few posts here about similar issues but couldn't find anything definitive.
Thanks for the help!
I had a similar problem with Facebook APi - it gave Response code 400 and Ive just tried:
composer require laravel/socialite & composer update
and it updated dependencies:
Updating dependencies (including require-dev)
Removing laravel/socialite (v2.0.11) - Installing laravel/socialite (v2.0.14)
Im Using Laravel 5.1:
composer.json:
"laravel/framework": "5.1.*",
"laravel/socialite": "^2.0"
And it seems to work fine now
Hope this helps someone
Please or to participate in this conversation.