I'm using Socialite
to authenticate my users via Facebook. However, I can't get it to work. I followed this tutorial, but I get the following error:
I looked everywhere and tried whatever, but I can't get it to work. Here's my code:
In services.php:
'facebook' => [
'client_id' => '[My App ID]',
'client_secret' => '[My App Secret]',
'redirect' => 'http://localhost:8000/auth/facebook/callback/',
],
My routes:
Route::group(['middleware' => ['web', 'requestlog']], function () {
Route::get('auth/facebook', 'Auth\AuthController@redirectToProvider');
Route::get('auth/facebook/callback/', 'Auth\AuthController@handleProviderCallback');
});
Then in my AuthController:
use Laravel\Socialite\Facades\Socialite;
public function redirectToProvider()
{
return Socialite::driver('facebook')->redirect();
}
public function handleProviderCallback()
{
try {
$providerUser = Socialite::driver('facebook')->user();
dd('yay it worked!');
} catch (RequestException $e) {
dd($e->getResponse()->json());
}
}
Then I have these settings in FB:
What is going wrong? I followed all the necessary steps as far as I know. I don't get what's wrong here. I hope I provided all the necessary information!
Edit
Here's what the url looks like on the page where the error displays:
http://localhost:8000/auth/facebook/callback?code=AQBtnKEqZgImLqN7f3hETe9GptgzFH71sXrV5qmv8Rpo6Oj5-4rl8mBjFPbfkBtiV8w9atV7X4OrWfHyalJkXU-k6lkEv1bly6v5Qxm2es-_RRp8gfoSWOZwjqE34Rvq6__L3aEOERPEa9LSBk_rKVP_cYGZoQeAydRLQUZVGdr_p1SuE1hRZIvZTAZ-zorkPoyyCDNZtDEVFHGRJt_c3kTf_AKE97FVemrXrUDzxaX-rvovKtfGF3u4CvAIt5pe4g7zD30jAWF78ZgjjPpr21MdaGwP5V0tc8g84oz0dR5Nbit7sKeUE-XblWFrQCIKfqs-OJ6rcuzw7iPTx6xrQ9Ev&state=4f924a9974207482c6fce24c1d74705c6688adc0#_=_
I also tried in incognito mode, removed cookies and so on. Same result...