jeudi 8 décembre 2016

Laravel - "An active access token must be used to query information about the current user." facebook

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:

enter image description here

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:

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:

enter image description here

enter image description here

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 nessecary information!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire