We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
morkus
3 years agoHelpful | Level 5
How to automate getting a new token using Java?
Now that DB uses "short-lived" tokens, I am having trouble "automating" token refresh within an application.
Using the Java code examples, I can get the DB URL where I manually have to log into...
- 3 years ago
Yes, that's correct. The SDK client knows how to use the credentials (refresh token, app key, and for the non-PKCE case, app secret) to automatically perform the refresh process whenever needed, so that calls continue to work.
morkus
Helpful | Level 5
So, are you saying that once I've gotten (but not done anything with it) a "refresh token", subsequent calls to DB will just ... work?
If so, that is fine since I can get the refresh token once and the user(s) would never be bothered with any timeouts.
Please clarify if correct.
Thanks!
Greg-DB
3 years agoDropbox Staff
Yes, that's correct. The SDK client knows how to use the credentials (refresh token, app key, and for the non-PKCE case, app secret) to automatically perform the refresh process whenever needed, so that calls continue to work.
- morkus3 years agoHelpful | Level 5
So ...
DbxRequestConfig config = DbxRequestConfig.newBuilder("dropbox-samplel").build();
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
client.refreshAccessToken(); // not necessary once you get a "refresh token" the first time.- Greg-DB3 years agoDropbox Staff
In this snippet, it looks like you're just passing in an access token string as that ACCESS_TOKEN variable. That constructor is for supplying just an access token. To use a refresh token, you would use the DbxClientV2(DbxRequestConfig requestConfig, DbxCredential credential) constructor (where the refresh token is in the DbxCredential), like in this example.
- morkus3 years agoHelpful | Level 5
OK. If it's automated after the first time, I suppose I don't need to worry about that code and specifically calling it. I've noted all the great replies you've helped me with for future changes. 🙂
Thanks!
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!