会话中缺少CSRF令牌 [英] Missing CSRF token in session

查看:520
本文介绍了会话中缺少CSRF令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,它可以从保管箱中获取文件和文件夹,并显示在网页中。我有以下代码。

I am creating the application which can fetch the files and folder from the dropbox and will show in the web page.I have the below code.

$appInfo=new Dropbox\AppInfo($dropboxKey,$dropboxSecret);
//store CSRF token
$csrfTokenStore = new Dropbox\ArrayEntryStore($_SESSION,'dropbox-auth-csrf-token');
$webAuth = new Dropbox\WebAuth($appInfo,$appName,'path',$csrfTokenStore);

当我执行代码时,出现以下错误:

when i execute the code i got the below error:


致命错误:未捕获的异常 Dropbox\WebAuthException_BadState,消息为会话中缺少CSRF令牌。

Fatal error: Uncaught exception 'Dropbox\WebAuthException_BadState' with message 'Missing CSRF token in session.


推荐答案

之所以出现此问题,是因为会话中没有 dropbox-auth-csrf-token 值。您检查ArrayEntryStore文件后就会知道,其中有 get(),set(),clear()之类的函数。这里的clear函数将取消设置csrf令牌。

The problem is happening because of there is no dropbox-auth-csrf-token value in the session.When you check the ArrayEntryStore files you get to know there are function like get(),set(),clear().Here clear function will unset the csrf token.

您需要做的是将csrf令牌值存储在数据库中,并且当同一用户需要获取该值并将其传递给 ArrayEntryStore 否则做同样的事情。

What you have to do is you need to store the csrf token value in database and when same user comes to need to fetch the value and pass it into the ArrayEntryStore else do the same.

这篇关于会话中缺少CSRF令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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