我在使用 Laravel Socialite 通过 Google API 登录用户时遇到了这个奇怪的问题。
一切配置看起来都很正常和普通,但我不断得到
错误缺少必需参数:代码
但是在本地主机中工作正常
本地主机:
服务器:
自动重定向的 URI http://example.com/subdir/auth/google/callback http://localhost:8000/auth/google/callback
经过一番查找,解决办法是把
profile
scopes
vendor\laravel\socialite\src\Two\GoogleProvider.php
protected $scopes = [ 'openid', 'email', ];
在我的例子中,当用户拒绝接受谷歌协议并且谷歌将用户重定向到带有错误查询参数的回调网址时发生错误,并且我忘记检查错误并继续让用户使用社交包。
回调响应示例:
https://example.com?error=access_denied&state=blahblah