您好,我正在使用Laravel Socialite通过远程Laravel Paspport应用进行Oauth身份验证。成功获取用户身份后,当我想让用户使用该应用程序时,它将重定向我重新登录并充当他的注销角色。客户端(Socialite在此git https://gitlab.fit.cvut.cz/ouredma3/trackage上)我尝试在设置中切换域,但无济于事。在实施Oauth之前,它运行良好。我会在https://socialiteproviders.netlify.app/providers/laravel-passport.html中使用Socialite 我希望它是您所需要的,但如果有任何我知道的内容,我将添加更多信息 Laravel 7.x,PHP 7.2
这是我的loginController。
public function redirectToProvider()
{
return Socialite::driver('laravelpassport')->redirect();
}
/**
* Obtain the user information from Passport
*
* @return \Illuminate\Http\Response
*/
public function handleProviderCallback(Request $request)
{
try {
$userSocial = Socialite::driver('laravelpassport')->stateless()->user();
} catch (\Exception $e) {
return redirect('/login')->withError($e->getMessage());
}
$users = User::where(['email' => $userSocial->getEmail()])->first();
if($users){
Auth::login($users,true);
}else{
$user = User::create([
'email' => $userSocial->getEmail(),
'provider_id' => $userSocial->getId()
]);
Auth::login($user,true);
}
//session(['current_user' => $userSocial]);
return redirect('/');
}
答案 0 :(得分:0)
好吧,我尝试将我的应用程序部署到服务器,并意外地使它起作用。.问题可能出在本地会话上。