我使用Socialite库进行谷歌登录。
当尝试在成功登录谷歌后获取用户数据时,它会显示一条无效的授权消息
$googleUser = Socialite::driver('google')->user();
响应
Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `400 Bad Request` response:
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
在我的本地机器和以前的laravel版本上运行的代码相同。
提前感谢
我遇到了同样的问题,下面的代码帮助了我:
$googleUser = Socialite::driver('google')
->with(['access_type' => 'offline'])
->user();
以下是有关的更多信息
试试这个
return Socialite::driver('google')->stateless()->user();
https://laravel.com/docs/7.x/socialite