Anybody?

I am trying to use Facebook with Laravel Socialite but I keep getting Bad Request errors from Guzzle and I honestly have no idea how to fix this.
If I copy and paste the url in the error, I get an access token response.
Anybody?

Have you tried turning it on and off again?
Serious: More info, can't tell what you're on about :)
Well I basically did this: https://laracasts.com/series/whats-new-in-laravel-5/episodes/9
But I used Facebook instead, now I get this:
Client error response [url] https://graph.facebook.com/oauth/access_token?client_id=805980719423812&client_secret=00f242e263af42a69bd1e986716f8c60&code=AQCUmRQp6ElbKDVig8n2luAnioWwcMQQDdy1FdlSRrogcne6p1ro0f2YoLCY96AZZmFqg8NMc3LBe9uu2LfhVwj6vJp7FykeKQtxcv-IzkOAlJ8Coctp-BCo2rwGpHAtlxZjST4mXyOh5s0i8JIRNFBpwA4Lu6MsGV9SSS-s6rcw1QuXg76UvqsaNf0Gn_kvFDxz5mWRPlXJ1rGhwpwCmrOJSUCw3shywvSgM9zy_tr5ZE73OrKQEnKbk3_tT4NPZl_1Zd-JVCGz19cnrmYkZWL0tdHIC8_7GWA15qRSEd3tfHt46oBgtidM_zRbXWb2uTfGbLY5FIy4pBucjHJ054hdGsP8cdLrBFuTisaIaQGtpw&redirect_uri=http%3A%2F%2F192.168.63.2%2Flogin [status code] 400 [reason phrase] Bad Request
I can copy and paste that url and it works fine, but guzzle craps out on it.
The Bad Request error means that your request is bad, Facebook is receiving data from you that is not valid: invalid configuration and invalid tokens are common causes. If the request URL is valid when you copy and paste it from the error message -- but isn't valid when the request is made by your application -- that would indicate that you have some form of hidden character somewhere, which your browser is removing and making the request valid.
The first step to debug would be to ensure that you're not introducing problems with your configuration: remove your Facebook entry from config/services.php and then start over, add it in again ensuring that your keys (and values) are all accurate.
Side note, a piece of advice for the future: debugging depends heavily on context, posting threads without any makes it very difficult to provide you help. If you're posting a help thread include any error messages at a minimum, and if you have any additional context add that too. For example this thread could have been:
"Hello, I'm following this episode on Laravel Socialite in Laravel 5 (using Facebook instead of GitHub) and when I try and login the following error message is displayed:
Client error response [url] https://graph.facebook.com/oauth/access_token?client_id=805980719423812&client_secret=00f242e263af42a69bd1e986716f8c60&code=AQCUmRQp6ElbKDVig8n2luAnioWwcMQQDdy1FdlSRrogcne6p1ro0f2YoLCY96AZZmFqg8NMc3LBe9uu2LfhVwj6vJp7FykeKQtxcv-IzkOAlJ8Coctp-BCo2rwGpHAtlxZjST4mXyOh5s0i8JIRNFBpwA4Lu6MsGV9SSS-s6rcw1QuXg76UvqsaNf0Gn_kvFDxz5mWRPlXJ1rGhwpwCmrOJSUCw3shywvSgM9zy_tr5ZE73OrKQEnKbk3_tT4NPZl_1Zd-JVCGz19cnrmYkZWL0tdHIC8_7GWA15qRSEd3tfHt46oBgtidM_zRbXWb2uTfGbLY5FIy4pBucjHJ054hdGsP8cdLrBFuTisaIaQGtpw&redirect_uri=http%3A%2F%2F192.168.63.2%2Flogin [status code] 400 [reason phrase] Bad Request
I can copy and paste that url and it works fine."
:)
I've done everything, still getting bad requests and I can't even debug what the actual error message returned by Facebook is.
Figured it out after going into vendor/laravel/socialite/src/Two/FaceBookProvider.php and wrapping the calls with try/catches to get the actual response from Facebook. Have to submit a pull request with these in it, because generic 400 errors are not helpful. I spent all night and half of today trying to figure this out.
So, what was the problem and how did you fix it? I am getting bad requests as well.
@troelsjohnsen I think the issue was probably with config/service.php
I was getting the same error until I had mine setup like this...
'facebook' => [
'client_id' => 'your-facebook-app-id',
'client_secret' => 'your-facebook-app-secret',
'redirect' => 'http://your-registered-call-back-url',
]
I think the confusion is with the 'client_secret' this needs to be your 'App Secret' (yes the one you need to type your password in for).
It's easy enough to assume that the required 'client_secret' for Socialite is the 'Client Token' under the 'Advanced' tab in the Facebook settings, which it isn't.
Had the very same problem here. A Four Hundred not helping at all, but... the information you need is in the ClientException object:

@antonioribeiro sorry because this is off-topic. But what software are you using in the screenshot above
@khoanguyenme, usually I only use MyImgur to create the Imgur link, but I had to edit this one, so I did:
@antonioribeiro I think @khoanguyenme wanted to know what software it was screenshot of lol
Looks to be xdebug remote debugging in PhpStorm.
can somebody post a step by step using the latest laravel 5 with facebook login
@antonioribeiro LOL. I want to know about what software it was screenshot like @deringer said.
FYI, I had the same error. I realized the callback url didn't match the one set in Facebook. It took a while do find it out. I had double // after the domain name, %2F%2F in url friend hex values.
I had this same error too, but none of the above solved my problem. It turns out that I needed to disable the "Require app secret for server API calls" setting in the Facebook app Advanced settings.
@Killswitchthe callback url should be matched with the one set in Facebook. Did you notice about that?
i am having this very same issue, i cleaned up the logs folder and after that it works fine, but when you return to your app it appears again, so according to @antonioribeiro 's log, i think that it is just because the facebook authorization code still in the log's cache, so i don't know if it is related to not logout from the app.
i found this in stackoverflow and it worked, i can't say that it is the appropriate way to do that but it worked for me.
file : AbstractProvider.php (two) line: 160 public function user() { //if ($this->hasInvalidState()) { // throw new InvalidStateException; //}
$user = $this->mapUserToObject($this->getUserByToken(
$token = $this->getAccessToken($this->getCode())
));
return $user->setToken($token);
}
same as you @Alain1405 pfff lucky to find this quick and not spent hours crying alone ^^
Hi ! in my case this error was related with a little javascript i've placed for clean de #_=_ url after de redirection , i've just quit and it works !
@Killswitch Did you find a solution?
as @deanhowe said , go to ur config/service
'facebook' => [
'client_id' => 'xxx', // Settings / Basic > APP ID
'client_secret' => 'xxx', // Settings / Basic > App Secret
'redirect' => 'http://localhost:8000/auth/facebook/callback', // FacebookLogin / Client OAuth Settings
],
I just encountered this problem and I fixed it by resetting my client token (Advanced > Security on the Facebook App settings page) and changing my app type from Native / Desktop to Web app.
I am still facing this problem, due to my understanding, I think it is because of the #_=_ in url after the posting with guzzle and redirection. But I don't know how to fix that. Anyone?
Your help is highly appreciated
Solved !! I too had the same problem and couldn't solve it so I changed back to GitHub and it worked so I decided it is basically set up with the, facebook account .
In my case the error was since the FaceBook App was set to Native or desktop app. selecting No to Native or desktop app? in Settings > Advanced fixed the things.
For some who hit this page like I did, it may be of some use.
Eu resolvi o meu problema retirando " / "do meu arquivo .env, estava assim "https://meusite.com/" Depois retirei a barra do final do endereço "/ "do final e funcionou! ;)
#2020
IDK if anybody had mentioned this above, I hadn't read all the answers
but I had missed the s in https
I have used callback URL in .env file without https and was using a callback URL with https in Facebook dashboard.
Please or to participate in this conversation.