简体   繁体   English

会话中缺少CSRF令牌

[英]Missing CSRF token in session

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. 我正在创建可以从Dropbox提取文件和文件夹并显示在网页中的应用程序。我有以下代码。

$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: 当我执行代码时,出现以下错误:

Fatal error: Uncaught exception 'Dropbox\\WebAuthException_BadState' with message 'Missing CSRF token in session. 致命错误:在会话中出现消息“缺少CSRF令牌”的未捕获异常“ Dropbox \\ WebAuthException_BadState”。

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. 发生问题是因为dropbox-auth-csrf-token没有dropbox-auth-csrf-token值。当您检查ArrayEntryStore文件时,您会知道有诸如get(),set(),clear()之类的函数。将取消设置csrf令牌。

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令牌值存储在数据库中,并且当同一用户需要获取该值并将其传递给ArrayEntryStore其他操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM