You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Pelleman
3 years agoExplorer | Level 4
How to create oauth2 access token from code?
Hello, I have written a backup solution and want to automatically post the backup file (a zip) to my Dropbox account every day when backup finishes.
How can I create an auth2 token by code and use ...
- 3 years ago
Hi Pelleman,
Access token received in whatever way is short lived and can't be used alone for a long time (4 hours, at most). For long term access (solution) you need to get to and store refresh token, which doesn't expire automatically. This token could be used to regenerate access token on demand and use the access token while valid for all regular API calls. For more info how you can get to such a refresh token and how you can automate "refreshing", take a look here. 😉
Hope this helps.
Greg-DB
Dropbox Staff
Pelleman 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 once. It's not possible to programmatically get an access token or refresh token using only the app key and secret.
As Здравко noted, Dropbox issues short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. Apps can get long-term access by requesting "offline" access though, in which case the app receives a "refresh token", which doesn't expire and can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation.
Pelleman
3 years agoExplorer | Level 4
Thanks for the help both of you, I think that refresh token solution suits my needs perfectly. I just tested it and it works as advertised.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 12 hours 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!