How to access dropbox using key and secret?

Viewed 23

I'm using a library: https://github.com/spatie/dropbox-api via composer to create folders in my dropbox , but a problem arose, I managed to use tokens but the token now expires after 4 hours (since 2021 actually) so I was trying to use the key and the secret, to access the dropbox. But I'm not getting it, do you need any other permissions to access?

if you have composer: composer require spatie/dropbox-api

<?php


require  __DIR__. '/vendor/autoload.php';


use Spatie\Dropbox\Client as DropboxClient;
use Spatie\Dropbox\Client as kS;
 use Spatie\Dropbox\TokenProvider ;
 use PHPUnit\Framework\TestCase;
 

//ACESS TOKEN
$token="your-token";
$appkey="your-key";
$appSecret="your-secret";
//Dropbox Client Instantiate


$obDropboxClient = new DropboxClient($token);

$save= new kS([$appkey,$appSecret]); 




//Create a Dropbox Folder



if(isset($_POST['submit'])) 
{
    $save->createFolder($_POST['n']);
    header("Location:dropbox.php?");
    die();
    

}





?>
<form action="dropbox.php" method="post">
   <p>Name: <input type="text" name="n" /></p>
   
   <input type="submit" name="submit" value="Submit" />
</form>






The error:

Fatal error: Uncaught Spatie\Dropbox\Exceptions\BadRequest in E:\XAMPP\htdocs\dropbox\vendor\Spatie\dropbox-api\src\Client.php:680 Stack trace: #0 E:\XAMPP\htdocs\dropbox\vendor\Spatie\dropbox-api\src\Client.php(668): Spatie\Dropbox\Client->determineException(Object(GuzzleHttp\Exception\ClientException)) #1 E:\XAMPP\htdocs\dropbox\vendor\Spatie\dropbox-api\src\Client.php(114): Spatie\Dropbox\Client->rpcEndpointRequest('files/create_fo...', Array) #2 E:\XAMPP\htdocs\dropbox\dropbox.php(33): Spatie\Dropbox\Client->createFolder('2424') #3 {main} thrown in E:\XAMPP\htdocs\dropbox\vendor\Spatie\dropbox-api\src\Client.php on line 680

0 Answers
Related