dropboxdropbox-apilaravel-9

Laravel 9 send files to multiple dropbox accounts with scheduled command


I have to send files to multiple dropbox accounts(users), so i need them to store some details related to account(tokens, to send files) and store them in database and later use that data to send files to dropbox (in laravel 9 how do i configure this and what are the details need to be stored to database to send file to users dropbox accounts)

Note: previously i tried with "spatie/flysystem-dropbox" to send files to a single dropbox account (by creating an App in dropbox App console and got the access_token using generate) and defined it in .env, that worked fine but when i tried it next day it says the access_token expired so i searched about that and got some details about refresh token.

can anyone help me with this (is there any other better packages to do this or is there any other way to do this, because the users can't normally know about generating refresh token, even if they did, do i have to manually write the code to check the refresh token expiration and change it!!


Solution

  • i have found a way , normally the access token for Dropbox lasts 4 hours, so basically it will expire after that period, so we have to get a new access token through refresh token and authorization code.

    As for my system requirement I have added some fields to get some details from users and generated a link to get authorization code with user consent and using that authorization code from user I sent a request to get the refresh token. while sending files to Dropbox first check if access token expired or not if expired get a new access token using the refresh token then send the files with new access token. (NOTE: authorization code is valid for 10minutes and one time use only).

    if you want more clarification you can check:
    https://www.dropboxforum.com/t5/Developer-API/ct-p/101000041