Learn how to make the most out of the Dropbox Community here 💙.
Forum Discussion
mauro991
3 years agoExplorer | Level 3
Python - Automatic Refresh_token Using oauth-2.0 with offlineaccess
OK I now: the automatic token refreshing is not a new topic.
This is the use case that generate my problem: let's say that we want extract data from Dropbox. Below you can find the code: for the f...
Здравко
3 years agoLegendary | Level 20
Hi mauro991,
The code you are talking about is for one time use. 🙂 This code is used as a confirmation when refresh token (and others) are going requested. Short after that it's no more valid. You need to keep the received refresh token and reuse it instead of the confirmation code. 😉 Refresh token doesn't expire automatically, but you don't even try to keep it somehow. Why are you requesting refresh token (offline access) while you don't use it actually? 🤷
Hope this helps.
- mauro9913 years agoExplorer | Level 3
Thanks for your answer but I can't solve the problem. May be that I am a bit confused, but according this official post I read "If your app needs to be able to operate long-term without the user present" read how to use “offline” access.
In any case can show me a code example where I can receive refresh token and reuse it instead using confirmation code?
Thanks
Mauro
- Здравко3 years agoLegendary | Level 20
Hi mauro991,
Yes, exactly, the reffered post is correct. One of my posts together with the interest to the matter provoked 'official post'. As result of setting "offline" mode, you are receiving refresh token and... instead using it as such (long lived), you are using it as a short lived one! This is your issue. There is no any restrictions how to keep it. It's your design decision.
Hope this sheds some light.
- Greg-DB3 years ago
Dropbox Staff
[Cross-linking for reference: https://stackoverflow.com/questions/74534382/dropbox-automatic-refresh-token-using-oauth-2-0-with-offlineaccess ]
mauro991 Здравко is correct; refresh tokens are long-lived, so you should re-use it. I see in your code you are already requesting offline access and getting back a refresh token. You should store and re-use that resulting refresh token for the user instead of having them process the authorization flow again each time. The dropbox.Dropbox client will handle the refresh process using the supplied refresh token automatically.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,963 PostsLatest Activity: 24 hours ago
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 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!