【问题标题】:InvalidStateException in AbstractProvider.php line 199 on production, Laravel 5.2.39生产中的 AbstractProvider.php 第 199 行中的 InvalidStateException,Laravel 5.2.39
【发布时间】:2016-12-02 16:11:24
【问题描述】:

我使用 Socialite 2.0 和 Laravel 5.2.39。 localhost:8000 上的社交登录正常工作,但在生产站点(example.com)上不起作用。

public function handleProviderCallback($provider) { $social_user = Socialite::driver($provider)->user(); .... }

调用Socialite::driver($provider)->user()函数时的异常错误为:

AbstractProvider.php 第 199 行中的 InvalidStateException

我尝试了人们建议的所有解决方案,但没有运气。 这是一些配置

SESSION_DRIVER=file DOMAIN=example.com URL=http://example.com (used in config/app.php) DOMAIN=mysite.com (used in config/session.php)

路线如下:

Route::get('redirect/{provider}', 'Auth\AuthController@redirectToProvider'); Route::get('callback/{provider}', Auth\AuthController@handleProviderCallback');

感谢您的帮助!

【问题讨论】:

  • 如果我使用Socialite::driver($provider)->stateless()->user(),会出现另一个错误:ClientException in RequestException.php line 107: Client error: `POST https://graph.facebook.com/oauth/access_token` resulted in a `400 Bad Request` response: {"error":{"message":"Missing authorization code","type":"OAuthException","code":1,"fbtrace_id":"EamBm42\/suf"}}
  • 终于找到了解决办法。它与 Nginx 配置有关。在文件 /etc/nginx/sites-available/ 上使用 try_files $uri $uri/ /index.php$is_args$args; 而不是 try_files $uri $uri/ /index.php$query_string;
  • 伙计,你刚刚救了我的命!把它作为一个答案,这个问题触动了很多人。

标签: laravel-5.2 laravel-socialite


【解决方案1】:

我终于找到了解决方案。它与 Nginx 配置有关。使用 try_files $uri $uri/ /index.php$is_args$args;而不是 try_files $uri $uri/ /index.php$query_string;在文件 /etc/nginx/sites-available/ 上。

【讨论】:

  • 嘿,我还是不明白。请解释更多。
猜你喜欢
  • 2017-05-01
  • 2017-04-28
  • 1970-01-01
  • 1970-01-01
  • 2015-06-20
  • 2016-01-29
  • 2016-05-26
  • 1970-01-01
  • 2018-01-05
相关资源
最近更新 更多