Discuss Dropbox Developer & API
Hi,
We need a java workflow to scan the contents of a shared folder on a daily basis. I have downloaded the examples and looked at AuthorizeExample which I ran with the parameters "test.app test.auth short_live_token". This code appears to requires clicking a dropbox link
to get an authorization code which is then used to generate a token and then the token can be used to list files in a folder. How can this all be done on the backend without human intervention? Are there any examples I can look at? With AWS S3 it's easily done with an access key and a secret key, I was hoping it would be similar.
Thanks, Jason
Let me make this clearer with code:
public DbxClientV2 createClient() throws DbxException {
DbxRequestConfig config = DbxRequestConfig.newBuilder("fingage").build();
DbxCredential dbxCredential = new DbxCredential(ACCESS_TOKEN, EXPIRES_AT, REFRESH_TOKEN, APP_KEY, APP_SECRET);
DbxTeamClientV2 teamClientV2 = new DbxTeamClientV2(config, dbxCredential);
PathRoot pathRoot = PathRoot.namespaceId("3103421521");
return teamClientV2.asMember("dbmid:AACV-hRckJZMB5ja-BpNuhN0PRjZod6__94").withPathRoot(pathRoot);
}
It appears this code will work in creating DbxCredential since the EXPIRES_AT is in the future. However if I run this code in a few days, will it still work? Is it the case that if the supplied expiresAt is in the past will it still be able to refresh the credential? Or can I just provide a value for expiresAt that is far into the future?
Thanks again
@novotny Yes, the expiration is only about the access token. The refresh token doesn't expire (though can be revoked on demand). If the expiration has passed, the client will use the refresh token to get a new access token automatically.
Something more: don't try change 'expireAt'. Your code will fail!!! There are ways to optimize your code but you need to keep entire credentials object and serialize and deserialize it. Don't change anything by hands there.
Ok so just to confirm even if the hardcoded credential I pass in to create DBTeamClientV2 has expired already (i.e. I run this code next week), it will simply use the refresh token to obtain a new one and everything should work.
Yes... 🙂
Hi there!
If you need more help you can view your support options (expected response time for a 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!