php - Laravel 5.1 - Facebook through Socialite (Client Error: 400) -


using this tutorial on laracast (laravel 5.0 - socialite), until min 12.11, have setup everything. however, using laravel 5.1

  • defined route commented out callback provider, trying fetch user details through taken token:

    route::get('auth/facebook', 'auth\authcontroller@redirecttoprovider'); //route::get('auth/facebook/aaa', 'auth\authcontroller@handleprovidercallback'); 
  • added necessities in config>services.php:

    'facebook' => [  'client_id' => '##',  'client_secret' => env('fb_secret_id'),  'redirect' => 'http://laratest.dev/auth/facebook',    ], 

i decided return same page (auth/facebook) now. that's why have set return domain.devv/auth/facebook testing.

  • in authcontroller.php, set:

    public function redirecttoprovider(authenticateuser $authenticateuser, request $request)  {      return $authenticateuser->execute($request->has('code'));  } 
  • and finally, in authenticateuser.php:

    use illuminate\contracts\auth\guard;  (ps. changed authenticator guard)     class authenticateuser {       private $users;       private $socialite;       private $auth;  public function __construct(userrepository $users, socialite $socialite, guard $auth)  {      $this->users = $users;      $this->socialite = $socialite;      $this->auth = $auth;  }   public function execute($hascode)  {       // dd($hascode) *first dd    if ( ! $hascode) return $this->getauthorizationfirst();    // $user = $this->socialite->driver('facebook')->user();    // dd($hascode) *second dd   // dd($user) *third dd  }  private function getauthorizationfirst()  {    return $this->socialite->driver('facebook')      ->scopes(['public_profile', 'email'])->redirect();  }  } 

now, clicking login facebook link , getting directed domain.dev/auth/facebook?code=943299043290...

when use *first dd (with other commented lines commented)- returns false.

when use *second dd (with commenting line $user = $this->socialite->driver('facebook')->user();), returns true.

so working perfect , goes through execute(), through getauthorizationfirst(). finally, returns execute() taken token contained in link (domain.dev/auth/facebook?code=943299043290...).


my problem arises here:

at second uncommenting $user = $this->socialite->driver('facebook')->user();, getting error:

clientexception in middleware.php line 69: client error: 400

1. in /applications/mamp/htdocs/laratest/vendor/guzzlehttp/guzzle/src/middleware.php line 69

2. @ middleware::guzzlehttp{closure}(object(response)) in promise.php line 199

3. @ promise::callhandler('1', object(response), array(object(promise), object(closure), null)) in promise.php line 152

4. @ promise::guzzlehttp\promise{closure}() in taskqueue.php line 60

5. @ taskqueue->run() in curlmultihandler.php line 96

this line ($user = $this->socialite->driver('facebook')->user();) not working me reasons (while in tutorial (min 12.11 15-second brief explanation).

whenever use $user = $this->socialite->driver('facebook')->user();, receive error clientexception in middleware.php line 69: client error: 400 and, of course, can't dd($user).

to add, when see clientexception error, link still code: (domain.dev/auth/facebook?code=943299043290...)

i having issue too, in case have add domain in config/session.php in domain field , add in app provider


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -