【问题标题】:dropbox php sdk error Missing CSRF token in sessiondropbox php sdk 错误在会话中缺少 CSRF 令牌
【发布时间】:2013-12-22 19:12:35
【问题描述】:

我在我的应用程序中使用 dropbox php sdk 我正在尝试使用以下代码访问核心 API

function getWebAuth()
{

$appInfo = dbx\AppInfo::loadFromJsonFile("../dropbox.json");
$clientIdentifier = "My-demo-app/1.0";
$redirectUri = "http://localhost/demo.app/public/dropbox-finish-oauth";
$csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri,$csrfTokenStore);

}

//My controller => http:://localhost/demo.app/public/dropbox

Route::get('dropbox',function(){

$authorizeUrl = getWebAuth()->start();

return Redirect::to($authorizeUrl);

});

//dropbox redirect uri

Route::get('dropbox-finish-oauth',function(){

  list($accessToken, $userId, $urlState) = getWebAuth()->finish($_GET);

});

第一个控制器一切正常,它重定向到 Dropbox 登录页面我填写用户名和密码,然后页面重定向到指定的 uri,我得到以下异常 csrf not found 异常

【问题讨论】:

    标签: php dropbox dropbox-api dropbox-php


    【解决方案1】:

    只是一个猜测,但请确保您在某处(在每次页面加载时)执行session_start()

    如果不是这样,那么调试的下一步可能是手动设置会话变量并在另一个页面上将其读回以验证会话存储是否正常工作。

    【讨论】:

    • tat 工作了,我只是在 getWebAuth() 函数中设置了 session_start(),嗯,我只花了 3 小时调试这个。除了将 session_start 放入该函数之外,我做了所有事情。谢谢人
    猜你喜欢
    • 2020-02-10
    • 2021-10-23
    • 2021-11-23
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-08
    • 2021-12-28
    • 1970-01-01
    相关资源
    最近更新 更多