We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
ogurchik222
2 years agoExplorer | Level 4
Re: Tokens only valid for 4 hours from app console
Hi, I am going to install Python Software on Linux server with no access to browser. Can you please tell me, can I automatically generate short-lived tokens to access Python Dropbox SDK without browser actions? If yes, can you please send me a link to a code snippet (WITH NO BROWSER ACTIONS) I can use only requests and your API.
Hi ogurchik222,
Unfortunately, in Dropbox Python SDK examples is not any like you are looking for. I have posted some time ago some code (not exactly what you ask for) which do the authentication flow (on first run) and actual work in the same module. You can split this code and use the part responsible for authentication flow on machine with browser (just a single call) and the other part on your browserless server. 😉 The configuration file, once created, can be copied in a way convenient for you on the same/equivalent place. I believe this example gives a way you can use in your Python Software.
Good luck.
- ЗдравкоLegendary | Level 20
Hi ogurchik222,
Unfortunately, in Dropbox Python SDK examples is not any like you are looking for. I have posted some time ago some code (not exactly what you ask for) which do the authentication flow (on first run) and actual work in the same module. You can split this code and use the part responsible for authentication flow on machine with browser (just a single call) and the other part on your browserless server. 😉 The configuration file, once created, can be copied in a way convenient for you on the same/equivalent place. I believe this example gives a way you can use in your Python Software.
Good luck.
- Greg-DBDropbox Staff
ogurchik222 As Здравко indicated, it is not possible to fully automate the OAuth process where the user chooses to authorize the app and the app then receives the resulting access token and optional refresh token. This needs to be done manually by the user at least once. If your app needs to maintain long-term access without the user manually re-authorizing it repeatedly, the app should request "offline" access so that it gets a refresh token. The refresh token doesn't expire and can be stored and used repeatedly to get new short-lived access tokens whenever needed, without the user manually reauthorizing the app. So, once you have the refresh token, no further browser interaction is required for that account.
We highly recommend using the official Dropbox Python SDK, which will handle the refresh process for you automatically. To set that up, make sure you're using the SDK as shown in the examples:
- https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-scopes.py
- https://github.com/dropbox/dropbox-sdk-python/blob/main/example/oauth/commandline-oauth-pkce.py
Once you have the refresh token, you can set up the client like shown at the end without manually running the authorization flow again.
- ogurchik222Explorer | Level 4
Thank you for your answers. I've found solution via using refresh token. It works for 2 days correctly already. IDK if I can share link from stackoverflow here, so I won't)
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months 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!