本文介绍了无法在流明5.2上使用社交名流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的流明配置名媛,但我得到了错误:

Here is my config socialite for lumen but I got error:

致命错误:在null上调用成员函数set()

Fatal error: Call to a member function set() on null

有什么主意吗?

我的AuthController

my AuthController

namespace App\Http\Controllers;
use Socialite;

class AuthController extends Controller {

public function redirectToProvider() {
  return Socialite :: driver('github')->redirect();
}

public function handleProviderCallback() {
  $user = Socialite :: driver('github')->user();
  dd( $user );
}
}

我的Route.php

my Route.php

$app->get('auth/github', 'AuthController@redirectToProvider');
$app->get('auth/github/callback', 'AuthController@handleProviderCallback');

我的bootstrap/app.php添加了

my bootstrap/app.phpadded this

class_alias(Laravel\Socialite\Facades\Socialite::class, 'Socialite');
$app->register(Laravel\Socialite\SocialiteServiceProvider::class);
$app->configure('services');

我的配置/服务

 return [
   'github' => [
    'client_id' => '############',
    'client_secret' => '#############',
    'redirect' => 'my callback url',
  ],
];


**


**

Fatal error: Call to a member function set() on null in D:\xampp\htdocs\user-service\vendor\laravel\socialite\src\Two\AbstractProvider.php on line 134
Whoops, looks like something went wrong.
1/1
FatalErrorException in D:\xampp\htdocs\user-service\vendor\laravel\socialite\src\Two\AbstractProvider.php line 134:
Call to a member function set() on null
in AbstractProvider.php line 134
at Application->handleShutdown() in RegistersExceptionHandlers.php line 55
at Application->Laravel\Lumen\Concerns\{closure}()

**

推荐答案

您首先需要通过以下两种方法更正Socialite调用:

You first need to correct your Socialite calls in your two methods:

public function redirectToProvider()
{
  return Socialite::driver('github')->redirect();
}

public function handleProviderCallback()
{
  $user = Socialite::driver('github')->user();
  dd( $user );
}

请勿在Socialite :: driver处使用空格.

重要更改流明5.2 (请参见发行说明)

Lumen 5.2中不再支持会话.如果您需要这些,则最好改用Laravel.

Sessions are not supported anymore in Lumen 5.2. If you need those you better use Laravel instead.

这篇关于无法在流明5.2上使用社交名流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 15:38