I am trying to use login with facebook in laravel 5 using Socialize.
Here is my route file code.
Route::get('fb', function ($facebook = "facebook")
{
$provider = \Socialize::with($facebook);
if (Input::has('code'))
{
$user = $provider->user();
return var_dump($user);
} else {
return $provider->scopes(['public_profile','user_friends'])->redirect();
}
});
login is success and I get the code but time of get $provider->user()
I get the error.
InvalidStateException in AbstractProvider.php line 161
Maybe this is better temporary solution
I got temporary solution for that.
comment the
$this->hasInvalidState()
if condition in AbstractProvider.php file and it's work fine.I don't know if this will help anyone but changing my session driver from
file
tocookie
solved theInvalidException
issue for me.Go to
vendor/guzzlehttp/guzzle/src/Client.php
change to
http://nhagiaodich.com/dang-nhap
It work on my website , just call ->stateless() before get user
you get this error because you have your social provider settings wrong in your config file or haven't set up your Facebook app properly.
Visit developers.facebook.com and make sure your app id and secret keys are correct and pointing to the correct URL. Then make sure your laravel app's services.php config file is updated with the correct redirect, id and secret.