Laravel 社交名媛:InvalidStateException [英] Laravel Socialite: InvalidStateException

查看:21
本文介绍了Laravel 社交名媛:InvalidStateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Laravel Socialite 在网站上添加 Facebook 连接按钮.有时,我在回调时遇到此错误:

I'm using Laravel Socialite to add a Facebook connect button on a website. Sometimes, I've got this error on callback:

exception 'LaravelSocialiteTwoInvalidStateException' 
in /example/vendor/laravel/socialite/src/Two/AbstractProvider.php:161

我不知道这是什么意思,也没有发现关于这个错误的任何信息.真正的问题是它似乎是一个随机异常(不明白为什么会发生).那么这个错误意味着什么以及如何避免它?

I don't know what it mean and did not found anything yet about this error. The real problem is it seems to be a random exception (don't understood why it happens). So what this error means and how to avoid it?

这似乎与 Laravel 5 在 AbstractProvider 中获取 InvalidStateException 的问题不同.php,因为在我的情况下它是随机的.

It seems it's not the same problem as Laravel 5 geting InvalidStateException in AbstractProvider.php, cause in my case it's random.

推荐答案

我昨晚遇到了这个问题,并通过以下解决方案解决了.

I ran into this issue last night and solve it with the following solution.

关于我的问题的更多信息,我有

More information on my issue, I've got

AbstractProvider.php 第 182 行中的 InvalidStateException

InvalidStateException in AbstractProvider.php line 182

在函数 handleProviderCallback() 中,当它从 Facebook 登录重定向回来时.好像和你的问题一样.

in the function handleProviderCallback() when it re-direct back from Facebook login. It seems to be the same as your issue.

此外,我发现当我在没有 www 的情况下打开我的网站时会出现我的问题.当我使用 www.mysite.com 打开我的网站时 - 没问题.起初我认为我的问题是随机的,直到我从 Chris Townsend 对问题的回复中得到了线索 - 非常感谢.

Furthermore I found my issue occurs when I open my site without www. When I open my site with www.mysite.com - no problem. At first I think my issue is random until I've got the clue by Chris Townsend's reply to the question - Thank you very much.

解决方案

  1. 转到您的 www 根目录,检查 Laravel 文件 config/session.php
  2. 检查会话会话 Cookie 域默认配置为 'domain' =>null, 我对 'domain' => 进行了更改'mysite.com'.
  3. 'php artisan cache:clear''composer dump-autoload' 之后,我可以从 www.mysite.commysite.com
  1. Go to your www root, check the laravel file config/session.php
  2. Check session Session Cookie Domain The default configuration is 'domain' => null, I made a change to 'domain' => 'mysite.com'.
  3. After 'php artisan cache:clear' and 'composer dump-autoload', I can login with no issue from both www.mysite.com and mysite.com

在完成这些修改后进行测试时,请务必从浏览器中删除您的 cookie.旧的 cookie 仍然会产生问题.

Be sure to delete your cookies from browser when testing it after these modifications are done. Old cookies can still produce problems.

这篇关于Laravel 社交名媛:InvalidStateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆