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

marcoalt's avatar
marcoalt
Explorer | Level 4
4 years ago

Java SDK issues with short lived token

Hi there, I need some help to migrate to the short lived token.

 

Normally I check if I have the token, then call or execute the other doprobx APIs (e.g. file upload):

Auth.startOAuth2Authentication(getActivity(), db_k);

 

While now I call:

Auth.startOAuth2PKCE(context, db_k, DbxRequestConfig.newBuilder("app")
.withHttpRequestor(new OkHttp3Requestor(OkHttp3Requestor.defaultOkHttpClient()))
.build(), Collections.singleton("files.content.write"));

 

Which gives me a token, that then I store, and re-use the following time and also for the actual operation:

DropboxClientFactory.init(accessToken);
PicassoClient.init(context, DropboxClientFactory.getClient());
DbxClientV2 mDbxClient = DropboxClientFactory.getClient();

mDbxClient.files().uploadBuilder("/"+recordingToExport.getName()+"_Features.csv")
.withMode(WriteMode.OVERWRITE)
.uploadAndFinish(inputStream);

How does this code change when using short lived access tokens?

 

Your documentation on github doesn't seem to use any of this, but obviously at the next call I get an error because the token expired.

 

Please help

    • vewert's avatar
      vewert
      Explorer | Level 4

      Hi, I am also looking to migrate to short-lived token. Thank-you for posting the usage examples.

       

      One question I have is, if I update my code, using startOAuth2PKCE method, will that affect my Access Token Expiration setting in appConsole (currently set to No Expiration) for other apps accessing Dropbox? Basically I just want to make sure that if I start testing with startOAuth2PKCE method, that it won't affect my current apps and users in production, as, in addition to an Android app, I have an iOS app and a Java Desktop app as well (which I plan to migrate later).

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        vewert No, just using the startOAuth2PKCE method will not change the "Access token expiration" setting in the App Console for any of your apps.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 Following

If 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!