We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.
Forum Discussion
dmartinez
2 years agoExplorer | Level 3
Acces token for python django
Hello, im trying to acces with a django porject to my own account files but the short live tokens renew each 4 hours i tried generating the offline token but it results on renewing it again, i am not that into oauth so im having issues on this part oculd someone helpme trying to get arround this issue, again is for my own account im using the list folder for downloading some fileds and working with panda but i want a permanent token for not having some to give permision to acces dropbox.
dmartinez Здравко is correct; for long-term access you should use a refresh token. Refresh tokens do not expire and can be used repeatedly. You do not need to re-authorize the app each time. Once you have a refresh token you can store and re-use that refresh token without further manual action.
The official Dropbox Python SDK will handle the details of how to use a refresh token for you, so you would just need to make the Dropbox client object like this, if you used PKCE to retrieve the refresh token:
dropbox.Dropbox(oauth2_refresh_token=REFRESH_TOKEN, app_key=APP_KEY)
or like this, if you did not use PKCE to retrieve the refresh token:
dropbox.Dropbox(oauth2_refresh_token=REFRESH_TOKEN, app_key=APP_KEY, app_secret=APP_SECRET)
For reference, you can find more information on how this works at the following resources:
- ЗдравкоLegendary | Level 20
Hi dmartinez,
For long term access you need refresh token. If a supported SDK is in use just proper initialization is enough (for the rest SDK takes care), otherwise tracing access token validity and refresh whenever needed should be performed. So you wouldn't need "to give permision to acces dropbox" (no repeatedly at least - only once at the beginning). 😉
Hope this gives direction.
- Greg-DBDropbox Staff
dmartinez Здравко is correct; for long-term access you should use a refresh token. Refresh tokens do not expire and can be used repeatedly. You do not need to re-authorize the app each time. Once you have a refresh token you can store and re-use that refresh token without further manual action.
The official Dropbox Python SDK will handle the details of how to use a refresh token for you, so you would just need to make the Dropbox client object like this, if you used PKCE to retrieve the refresh token:
dropbox.Dropbox(oauth2_refresh_token=REFRESH_TOKEN, app_key=APP_KEY)
or like this, if you did not use PKCE to retrieve the refresh token:
dropbox.Dropbox(oauth2_refresh_token=REFRESH_TOKEN, app_key=APP_KEY, app_secret=APP_SECRET)
For reference, you can find more information on how this works at the following resources:
- dmartinezExplorer | Level 3
thank you, i was testing this approach this days i delivered the app and just gave it the autorization and still working, thank you for the help !
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,875 PostsLatest Activity: 13 minutes agoIf 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!