Laravel 5.2 / Socialite FatalErrorException in AbstractProvider.php line 134: -
getting following error when using socialite authenticate facebook. using laravel 5.2 , first time trying implement socialite. ideas ?
fatalerrorexception in abstractprovider.php line 134: call member function set() on non-object route :-
route::get('/login', 'authcontroller@login'); authcontroller.php :-
<?php namespace app\http\controllers; use illuminate\http\request; use app\http\requests; use app\http\controllers\controller; class authcontroller extends controller { public function login() { return \socialite::with('facebook')->redirect(); } } services.php setup follows details in .env file :-
'facebook' => [ 'client_id' => env('facebook_client_id'), 'client_secret' => env('facebook_client_secret'), 'redirect' => env('facebook_redirect'), ], the same error reported here no response :- https://laracasts.com/discuss/channels/laravel/laravel-socialite-session-errors-in-52/replies/125233
had same problem...
found answer here: in routes.php, did define routes inside web middleware group? seems common problem 5.2 upgrades :)
it looks have put routes in middleware because includes session creation needed in abstractprovider.php 134
$this->request->getsession()->set('state', $state = str::random(40)); this how code routes.php looks (and works):
<?php /* |-------------------------------------------------------------------------- | routes file |-------------------------------------------------------------------------- | | here register of routes in application. | it's breeze. tell laravel uris should respond | , give controller call when uri requested. | */ route::get('/', function () { return view('welcome'); }); route::get('admin', function () { return view('admin_template'); }); route::get('test', 'testcontroller@index'); /* |-------------------------------------------------------------------------- | application routes |-------------------------------------------------------------------------- | | route group applies "web" middleware group every route | contains. "web" middleware group defined in http | kernel , includes session state, csrf protection, , more. | */ route::group(['middleware' => ['web']], function () { // route::get('auth/google', 'auth\authcontroller@redirecttoprovider'); route::get('auth/google/callback', 'auth\authcontroller@handleprovidercallback'); });
Comments
Post a Comment