laravel socialite在实时服务器上不起作用,仅在本地计算机上工作

编程入门 行业动态 更新时间:2024-10-26 00:21:56
本文介绍了laravel socialite在实时服务器上不起作用,仅在本地计算机上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近将我的应用程序移到了实时服务器中. 问题是laravel社交名流停止了工作,以下是说明: 我单击Google登录名,然后选择电子邮件,然后在回调中发生这种情况: InvalidStateException on Abstract.php on line 200. 要解决此问题,我使用了stateless(),现在新的错误是: Client error: `POST www.googleapis/oauth2/v4/token` resulted in a `400 Bad Request` response: { "error": "invalid_request", "error_description": "Missing required parameter: code" }

I have recently moved my application into a live server. The problem is laravel socialite stopped working, below is the explanation: I click on google login and after choosing email, on callback this happens: InvalidStateException on Abstract.php on line 200. To fixed this issue i used stateless() and now the new error is : Client error: `POST www.googleapis/oauth2/v4/token` resulted in a `400 Bad Request` response: { "error": "invalid_request", "error_description": "Missing required parameter: code" }

以下是我已经尝试过的事情清单: 1-在Google网站中,我将google api url和callback url更新为新的实时域名地址: www.domain-name和www.domain-name/login/google/callback

Here is the list of things i have already tried: 1- In Google website, I updated google api url and callback url to new live domain addresses: www.domain-name and www.domain-name/login/google/callback

2-我修改了config/session.php文件,如下所示: 'domain' => env('SESSION_DOMAIN', 'www.domain-name'),

2- I have modified config/session.php file like this: 'domain' => env('SESSION_DOMAIN', 'www.domain-name'),

3-我的存储文件夹已经具有这样的权限: drwxrwxr-x 5 root www-data 4096 Jun 24 18:30 storage

3- My storage folder is already have permission like this: drwxrwxr-x 5 root www-data 4096 Jun 24 18:30 storage

4-我更改了vendor\laravel\socialite\src\Two\GoogleProvider.php文件并删除了配置文件",现在看起来像这样:

4- I changed vendor\laravel\socialite\src\Two\GoogleProvider.php file and removed 'profile' and now it looks like this:

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

5-我使用了php artisan cache:clear,composer dump-autoload,并多次清除了浏览器缓存数据.

5- I used php artisan cache:clear , composer dump-autoload, and cleared browser cache data many times.

6-我尝试使用$userSocial = Socialite::with('google')->user();而不是$userSocial = Socialite::driver('google')->user();,但我仍然得到InvalidStateException on Abstract.php on line 200.仅当我更改为$userSocial = Socialite::driver('google')->stateless()->user();时,错误才会更改为我在问题开始时所说的内容.

6- I tried $userSocial = Socialite::with('google')->user(); instead of $userSocial = Socialite::driver('google')->user(); , and i still get InvalidStateException on Abstract.php on line 200. only when i change to $userSocial = Socialite::driver('google')->stateless()->user(); the error changes to what i said at the beginning of the question.

我的config/services.php文件是这样的:

'google' => [ 'client_id' => 'my-correct-client-id-from-google', 'client_secret' => 'my-correct-client-secret-from-google', 'redirect' => 'www.domain-name/login/google/callback', ],

我已经尝试修复此问题2天了.任何帮助将不胜感激.

I have been trying to fix this for 2 days now. any help would be appreciated.

推荐答案

浪费了许多小时.终于找到了答案: 那是nginx: 所以我跑了sudo nano /etc/nginx/sites-available/default

after many hours wasted. finally found the answer: it was nginx: so i ran sudo nano /etc/nginx/sites-available/default

并修复此行:

try_files $uri $uri/ /index.php?query_string; // wrong

try_files $uri $uri/ /index.php?$query_string; // fixed

更多推荐

laravel socialite在实时服务器上不起作用,仅在本地计算机上工作

本文发布于:2023-11-01 17:40:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549978.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:机上   上不   实时   服务器   工作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!