Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
FrancoisNOYEZ
5 years agoExplorer | Level 4
How to migrate to new Auth workflow with python SDK while minimizing need for single user input?
Hello Dropbox team,
I have set up a small app as a python script which runs continuously on my server, and which needs to read some files that I store on my Dropbox storage space, in the folder...
- 5 years ago
FrancoisNOYEZ Здравко is correct, under the new system you do not need to interact with your script every time it runs. You can supply it the refresh token like you previously supplied it a long-lived access token and it will automatically run without manual user interaction, as before.
You do need to process the app authorization flow one time to get a refresh token though. You can refer to this example to see how to process the app authorization flow to get a refresh token, at which point you can then set up a client using it, as shown at the end of the example.
Greg-DB
Dropbox Community Moderator
3 years agotszikszai You need to supply the refresh token to the dropbox.Dropbox constructor so it can use it to perform the refresh automatically when needed. Please refer to the example of how to construct that with a refresh token here.
tszikszai
3 years agoExplorer | Level 3
I guess I am just trying to get to the next line of code of how to use this client to actually upload a file to Dropbox. Could you give me a code example?
- Greg-DB3 years ago
Dropbox Community Moderator
tszikszai Once you have a client constructed with a refresh token, you can use it to upload a file the same was as before, by calling files_upload.
Here's some simplified code from the example, combined with some of your uploading code, as an example:
import dropbox APP_KEY = "APPKEYEHERE" APP_SECRET = "APPSECRETHERE" REFRESH_TOKEN = "REFRESHTOKENHERE" dbx = dropbox.Dropbox(oauth2_refresh_token=REFRESH_TOKEN, app_key=APP_KEY, app_secret=APP_SECRET) local_file_path = "/local/path/here" dropbox_path = "/destination/path/here" with open(local_file_path, 'rb') as f: result = dbx.files_upload(f.read(), dropbox_path, mode=dropbox.files.WriteMode.overwrite) print(result) - tszikszai3 years agoExplorer | Level 3
Thank you!!!! Exactly what I was looking for!!
About Dropbox API Support & Feedback
Find help with the Dropbox API from 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!