Laravel Socialite - 谷歌登录失败“缺少必需的参数:代码”

问题描述 投票:0回答:2

我在使用 Laravel Socialite 通过 Google API 登录用户时遇到了这个奇怪的问题。

一切配置看起来都很正常和普通,但我不断得到

错误缺少必需参数:代码

但是在本地主机中工作正常

本地主机: enter image description here

服务器: enter image description here

自动重定向的 URI http://example.com/subdir/auth/google/callback http://localhost:8000/auth/google/callback

php laravel google-api laravel-5.6 laravel-socialite
2个回答
3
投票

经过一番查找,解决办法是把

profile
中的
scopes
中的
vendor\laravel\socialite\src\Two\GoogleProvider.php
去掉

protected $scopes = [
    'openid',
    'email',
];

0
投票

在我的例子中,当用户拒绝接受谷歌协议并且谷歌将用户重定向到带有错误查询参数的回调网址时发生错误,并且我忘记检查错误并继续让用户使用社交包。

enter image description here

回调响应示例:

https://example.com?error=access_denied&state=blahblah

© www.soinside.com 2019 - 2024. All rights reserved.