这是我的流明配置社交网站,但我收到了错误:
致命错误:在null
上调用成员函数set()有什么想法吗?
我的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
$app->get('auth/github', 'AuthController@redirectToProvider');
$app->get('auth/github/callback', 'AuthController@handleProviderCallback');
我的bootstrap / app.php 添加了这个
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}()
**
答案 0 :(得分:0)
您首先需要通过两种方法更正您的社交名媛呼叫:
public function redirectToProvider()
{
return Socialite::driver('github')->redirect();
}
public function handleProviderCallback()
{
$user = Socialite::driver('github')->user();
dd( $user );
}
请勿在{{1}}使用空格。
重要更改Lumen 5.2 (请参阅release notes)
Lumen 5.2代表着减轻Lumen的转变,专注于提供无状态的JSON API。因此,框架不再包含会话和视图。
Lumen 5.2不再支持会话。如果你需要那些,你最好使用Laravel。