We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
MightyModest
4 years agoExplorer | Level 3
Refresh token not valid
I'm building a Flask app that sends files users post on their account to a shared Dropbox folder. It works fine with these short-lived 4-hour tokens, but as I prepare to move to deployment I need a l...
Здравко
4 years agoLegendary | Level 20
Hi MightyModest,
You are doing well initial authorization steps! 😉 So, you already have all needed to be able perform regular API calls. The API calls accept access tokens only, NOT refresh token!!! That's where start your errors. First, don't try replace the access token with refresh token - as you know already it doesn't work. Second as "refresh token" name suggest, it's a token to refresh the access token and can't be used for something else. 😉 By the way... 🤔 have you refreshed the access token once the initial one got expire? Ohh... 🤫 seems not! Try it - may work. 😉 Take a look here for a more complete example.
Hope this helps.
- MightyModest4 years agoExplorer | Level 3
Thanks for clarifying on the refresh token. I think my confusion is about how to implement a Python-specific way of using that refresh token to constantly grab a new short-lived token. Right now my app does the following (which works with a short-lived token in my environmental variables):
import dropbox client = dropbox.Dropbox(dropbox_access_token) uploaded = client.files_upload(open(local_file_path, "rb").read(), dropbox_path) shared_link = client.sharing_create_shared_link(dropbox_path)I've searched for an example of how I can programmatically (I imagine via a cron job that runs more frequently than the four hour expiration time) use my refresh token to update `dropbox_access_token` above. I'm sure there's a code example but I just can't find it, likely because I'm not using the right terminology.
- Здравко4 years agoLegendary | Level 20
MightyModest wrote:... I think my confusion is about how to implement a Python-specific way of using that refresh token to constantly grab a new short-lived token. ... I've searched for an example of how I can programmatically (I imagine via a cron job that runs more frequently than the four hour expiration time) use my refresh token to update `dropbox_access_token` above. ...
😀 No, you will not find such a example and it's not need while using any of Dropbox supported SDKs (including Python). Refresh is performed by the client object internally whenever needed - on demand. The only thing you need is to provide full credentials (including refresh token), so refresh to be possible. 😉 Take a look here for a something like very simple example. Don't try perform refresh yourself; in such a way you will double existing code - something meaningless. Ahh.. it's still possible of course...
Good luck.
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!