dropbox php sdk error Missing CSRF token in session

1.6k views Asked by At

I am using dropbox php sdk form my app i am trying to access core API using following code

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);

});

Everything is fine in first controller it redirects to dropbox login page i fill in username and password and then page is redirect to specified uri and i get following exception csrf not found exception

1

There are 1 answers

1
user94559 On BEST ANSWER

Just a guess, but make sure you're doing session_start() somewhere (on every page load).

If that's not it, perhaps the next step in debugging would be to manually set a session variable and read it back out on another page to verify that session storage is working.