dimanche 20 mars 2016

Laravel with Socialize(fb) say: InvalidStateException in AbstractProvider.php line 150:

I try to implement http://ift.tt/1kNinWg at my Laravel 5.1 project.

So as I read at documentation I write: at services.php

'facebook' => [
    'client_id' =>  env('FACEBOOK_APP_ID'),
    'client_secret' => env('FACEBOOK_APP_SECRET'),
    'redirect' => env('FACEBOOK_REDIRECT'),
],

also at app.php I add:

    Laravel\Socialite\SocialiteServiceProvider::class,

and aliases:

'Socialite' => Laravel\Socialite\Facades\Socialite::class,

Now at AuthController I add:

public function redirectToProvider($provider)
{
    return Socialite::driver($provider)->redirect();
}

 public function handleProviderCallback($provider)
{
 //notice we are not doing any validation, you should do it

    $user = Socialite::driver($provider)->user();

    // stroing data to our use table and logging them in
    $data = [
        'name' => $user->getName(),
        'email' => $user->getEmail()
    ];

    Auth::login(User::firstOrCreate($data));

    //after login redirecting to home page
    return redirect($this->redirectPath());
}

and route.php:

Route::get('/social/login/redirect/{provider}', ['uses' => 'Auth\AuthController@redirectToProvider', 'as' => 'social.login']);
Route::get('/social/login/{provider}', 'Auth\AuthController@handleProviderCallback');

But NOW when I try to go at http://ift.tt/1RXWfTG I get: enter image description here

What is wrong? WHere I make error? Hw to solve this problem?

UPDATE: MY .env file is:

FACEBOOK_APP_ID=1746848740002084
FACEBOOK_APP_SECRET=e7055b8588808b4026098d3c44241d98
FACEBOOK_REDIRECT=http://ift.tt/1RXWfTI



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire