“状态"URL 和会话中的参数不匹配 [英] The "state" param from the URL and session do not match

查看:22
本文介绍了“状态"URL 和会话中的参数不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 facebook 文档中

In facebook documantion

require('include/facebook/autoload.php'); //SDK directory
$fb = new FacebookFacebook([
'app_id' => '***********',
'app_secret' => '***********************'
]);

$helper = $fb->getRedirectLoginHelper();
$permissions = ['email', 'public_profile']; // optional
$loginUrl = $helper->getLoginUrl('http://www.meusite.com.br/login-callback.php', $permissions);

当指向 url $loginUrl 时,返回是:Facebook SDK 返回错误:跨站请求伪造验证失败.URL 和会话中的状态"参数不匹配

When direct it to the url $loginUrl, the return is: Facebook SDK returned an error: Cross-site request forgery validation failed. The "state" param from the URL and session do not match

推荐答案

我遇到了同样的错误.

问题发生是因为我在 getAccessToken() 之前做了 getLoginUrl(...)

The problem occurred because I did getLoginUrl(...) before getAccessToken()

所以在重定向的 URL 和代码中去掉 getLoginUrl(...) 应该可以工作.

So rid of getLoginUrl(...) in redirected URL and code should works.

这篇关于“状态"URL 和会话中的参数不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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