I followed this http://ift.tt/2eXXkAl tutorial on how to use laravel socialite, although i am using laravel 5.3, the syntax still works fine for me.
Problem
The problem is that when i click my fb login link, which refers to my callback function in my AuthController. I get stuck on the callback link with a url lke this localhost:8000/callback?code=<very long code here>
, and then when i try to refresh the browser, it gives me this error InvalidStateException in AbstractProvider.php line 200
.
Code
This is the callback function
public function handleProviderCallback()
{
$user = Socialite::driver('facebook')->user();
}
Redirect function
public function redirectToProvider()
{
return Socialite::driver('facebook')->redirect();
}
My routes
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index');
Route::get('/redirect', 'Auth\AuthController@redirectToProvider');
Route::get('/callback', 'Auth\AuthController@handleProviderCallback');
Notes
Before this error happened, i have already made the facebook pop-up work but then i got the cacert.pem error. But i already fixed that by downloading the cacert.pem and configuring php.ini.
Things i've tried
I tried using dd on the $user
and the output is this:
User {#192 ▼
+token: "EAAEjWyWCELYBANza7O7zUIWqYyxG6nZBO8EcuTLCxIeyJ9qP3bcpgrVVxyQpqbTAIHx7ZA69UDs56pWQUca3ZBo7FUSt9cV4kWkhxw3KqbhDJGesB4gvOK95XYQ4QGuRZBABNRNztGrWwD5bZAB2ZApIhIiiHbiW0ZD"
+refreshToken: null
+expiresIn: "5157925"
+id: "1350466991653065"
+nickname: null
+name: "<my name>"
+email: "<my email>"
+avatar: "http://ift.tt/2eGa4Ns"
+user: array:6 [▶]
+"avatar_original": "http://ift.tt/2eXSCTg"
+"profileUrl": "http://ift.tt/2eG9pM5"
}
I replaced my name and email there.
Any help would be much appreciated!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire