我的生产环境中出现Laravel Socialite的Google身份验证问题。错误与这篇文章相同:
laravel socialite not working on live server, only works on local machine
但是我有一个Apache服务器,经过多次尝试,我没有找到解决方案。
修改:
客户端错误:POST“ https://www.googleapis.com/oauth2/v4/token”导致“ 400错误请求” 回应:
{
"error": "invalid_request",
"error_description": "Missing required parameter: code"
}
答案 0 :(得分:1)
public function redirectToProvider($driver)
{
// return Socialite::driver($driver)->stateless()->redirect();
return Socialite::driver('google') ->setScopes(['openid', 'email'])
->redirect();
}
答案 1 :(得分:0)
发生此问题是由于 vendor \ laravel \ socialite \ src \ Two \ GoogleProvider.php 中的配置文件范围。
您可以通过以下两种方法克服此错误:
{
"env": {
"browser": true,
"node": true,
"es2021": true
},
"plugins": ["vue"],
"extends": ["eslint:recommended", "plugin:vue/recommended"],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"no-console": "off",
"no-var": 2,
"indent": ["warn", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
}
}
protected $scopes = [
'openid',
'email',
];