I am using https://github.com/kunalvarma05/dropbox-php-sdk for my php project to upload files at dropbox.
Here I do not required any user to use dropbox its just for internal users so i can upload files at my dropbox.
I Generated access token from Dropbox app and everything working but token is getting expired after some time. I did one time Oauth login to regenerate token but new token also expired after some time.
How can i regenerate token or get long-lived token so at backend, so my script can upload files at dropbox after every new upload by user's?
I am using this simple code
include('dropbox/vendor/autoload.php');
$app = new DropboxApp("client_id", "client_secret", 'access_token');
$dropbox = new Dropbox($app);
$data = []; // here getting list of files from database
if (!$data->isEmpty()) {
foreach ($data as $list) {
$filePath = 'folder_path/'.$list->file_name;
$fileName = $list->file_name;
try {
// Create Dropbox File from Path
$dropboxFile = new DropboxFile($filePath);
// Upload the file to Dropbox
$uploadedFile = $dropbox->upload($dropboxFile, "/folder_name/" . $fileName, ['autorename' => true]);
// File Uploaded
echo $uploadedFile->getPathDisplay();
} catch (DropboxClientException $e) {
print_r($e->getMessage());
}
}
}