We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
jordonshaw
7 years agoHelpful | Level 5
Cron job to upload files from server to Dropbox
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...
- 7 years ago
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:
- check if it has an access token stored already
- if it does, use that existing access token
- if it doesn't, send the user through the app authorization flow to get an access token, and store the resulting access token
- call the API to upload the file(s)
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.
- check if it has an access token stored already
Greg-DB
Dropbox Community Moderator
7 years agoThe 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:
- check if it has an access token stored already
- if it does, use that existing access token
- if it doesn't, send the user through the app authorization flow to get an access token, and store the resulting access token
- call the API to upload the file(s)
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.
jordonshaw
7 years agoHelpful | Level 5
I wondered if that might be the case. Thank you so much for your help!
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
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!