drdr123456 2016-01-06 05:30
浏览 36

AbstractProvider.php第134行中的Laravel 5.2 / Socialite FatalErrorException:

Getting the following error when using Socialite to authenticate with Facebook. Using Laravel 5.2 and this is the first time I am trying to implement Socialite. Any ideas ?

FatalErrorException in AbstractProvider.php line 134:
Call to a member function set() on a 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 as follows with details in the .env file :-

'facebook' => [
    'client_id'     => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect'      => env('FACEBOOK_REDIRECT'),
],

The same error was reported here but no response :- https://laracasts.com/discuss/channels/laravel/laravel-socialite-session-errors-in-52/replies/125233

  • 写回答

3条回答 默认 最新

  • dourao3960 2016-01-06 11:54
    关注

    Had the same problem...

    Found an answer here: in routes.php, did you define your routes inside the web middleware group? This seems to be a common problem with 5.2 upgrades :)

    It looks like you have to put your routes in a MiddleWare because it includes Session creation which is needed in the AbstractProvider.php 134

    $this->request->getSession()->set('state', $state = Str::random(40));
    

    This is how my code routes.php looks like now (and works):

        <?php
    
    /*
    |--------------------------------------------------------------------------
    | Routes File
    |--------------------------------------------------------------------------
    |
    | Here is where you will register all of the routes in an application.
    | It's a breeze. Simply tell Laravel the URIs it should respond to
    | and give it the controller to call when that URI is requested.
    |
    */
    
    Route::get('/', function () {
        return view('welcome');
    });
    
    Route::get('admin', function () {
        return view('admin_template');
    });
    
    Route::get('test', 'TestController@index');
    
    
    /*
    |--------------------------------------------------------------------------
    | Application Routes
    |--------------------------------------------------------------------------
    |
    | This route group applies the "web" middleware group to every route
    | it contains. The "web" middleware group is defined in your HTTP
    | kernel and includes session state, CSRF protection, and more.
    |
    */
    
    Route::group(['middleware' => ['web']], function () {
        //
        Route::get('auth/google', 'Auth\AuthController@redirectToProvider');
        Route::get('auth/google/callback', 'Auth\AuthController@handleProviderCallback');
    
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因