Discuss Dropbox Developer & API
I've been able to create a PHP app that allows me to upload files through the API into dropbox. It works great; however, the problem is, the first time you access it, you have to authenticate to get the token and then it's able to work. This all requires interaction of a user to do so. My goal is to create a cron job that will run hourly and copy any new files from a folder into my dropbox in order to have a backup copy of the files. Is this possible? If so, can anyone point me in the direction of an example?
Thank you!
The token you get back after authorizing the app is called an "access token", and is specific to that particular app-user pair. Access tokens for your app don't expire by default, so once the app receives one, you can have it store and re-use it, so it can make API calls in the future for that user without further manual user intervention.
So, you'll probably want to have your app do something like this each time it runs:
I don't have a sample of this to share in PHP though. Exactly what mechanism you use to store the access token will depend on what platform and libraries you're using. Keep in mind that the access token does enable access to the account, so you should store it securely.
The token you get back after authorizing the app is called an "access token", and is specific to that particular app-user pair. Access tokens for your app don't expire by default, so once the app receives one, you can have it store and re-use it, so it can make API calls in the future for that user without further manual user intervention.
So, you'll probably want to have your app do something like this each time it runs:
I don't have a sample of this to share in PHP though. Exactly what mechanism you use to store the access token will depend on what platform and libraries you're using. Keep in mind that the access token does enable access to the account, so you should store it securely.
I wondered if that might be the case. Thank you so much for your help!
What if you are not acting on behalf of the users? For example, in my case, we are just pushing files to Dropbox as part of an app-sync/integration. Do we need to provision an API user and build a UI around re-authenticating them?
@caseyprovost In order to upload to Dropbox via the Dropbox API, you need to upload to some particular user account. If you don't need to connect to arbitrary end-user accounts, and are just connecting to your own account, for instance, you don't need to build the app authorization flow and UI. You can just get your own access token once and use that.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!