<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Dropbox Java client for Android: how to refresh token? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712103#M31537</link>
    <description>&lt;P&gt;My app just needs to upload a backup file to a dropbox account from mine, so the access must be off-line (no prompting to the user, that would be confusing). This is carried out when the user finishes inputting data. I previously used the API with the following code (Java SDK):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DbxRequestConfig config = DbxRequestConfig.newBuilder( getPackageName() ).build();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DbxClientV2 client = new DbxClientV2( config, getString( R.string.dropbox_token ) );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;client.files()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;.uploadBuilder( toPath )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;.withMode( WriteMode.OVERWRITE )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;.uploadAndFinish( in );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But now this does not work anymore, or better speaking, it works but the token expires, so it only works once. I've looked the docs for the Java SDK, but there doesn't seem to be a simple example for offline access.&lt;/P&gt;
&lt;P&gt;What I tried so far:&lt;BR /&gt;- I obtained an access token, that allows the initial authentication.&lt;BR /&gt;- I substituted the generated short-lived token with an access token. But this does not work by itself.&lt;BR /&gt;- There is a promising method in the client that refreshes a token, so I tried calling it and creating a new client, before uploading the file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;try {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbxRefreshResult result = client.refreshAccessToken();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbxCredential credentials = new DbxCredential(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_token ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Long.MAX_VALUE,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; result.getAccessToken(),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_key ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_secret ) );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;client = new DbxClientV2( config, credentials );&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;} catch (DbxException e) {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.err.println( "Error refreshing token: " + e.getMessage());&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The refreshing apparently works (no errors, at least), but then the upload fails with a new error: invalid_access_token.&lt;/P&gt;
&lt;P&gt;So, should I create a new client with the refresh token or not? Am I refreshing the token correctly?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2023 13:31:52 GMT</pubDate>
    <dc:creator>baltasarq</dc:creator>
    <dc:date>2023-09-07T13:31:52Z</dc:date>
    <item>
      <title>Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712103#M31537</link>
      <description>&lt;P&gt;My app just needs to upload a backup file to a dropbox account from mine, so the access must be off-line (no prompting to the user, that would be confusing). This is carried out when the user finishes inputting data. I previously used the API with the following code (Java SDK):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DbxRequestConfig config = DbxRequestConfig.newBuilder( getPackageName() ).build();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DbxClientV2 client = new DbxClientV2( config, getString( R.string.dropbox_token ) );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;client.files()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;.uploadBuilder( toPath )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;.withMode( WriteMode.OVERWRITE )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;.uploadAndFinish( in );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But now this does not work anymore, or better speaking, it works but the token expires, so it only works once. I've looked the docs for the Java SDK, but there doesn't seem to be a simple example for offline access.&lt;/P&gt;
&lt;P&gt;What I tried so far:&lt;BR /&gt;- I obtained an access token, that allows the initial authentication.&lt;BR /&gt;- I substituted the generated short-lived token with an access token. But this does not work by itself.&lt;BR /&gt;- There is a promising method in the client that refreshes a token, so I tried calling it and creating a new client, before uploading the file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;try {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbxRefreshResult result = client.refreshAccessToken();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbxCredential credentials = new DbxCredential(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_token ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Long.MAX_VALUE,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; result.getAccessToken(),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_key ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_secret ) );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;client = new DbxClientV2( config, credentials );&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;} catch (DbxException e) {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.err.println( "Error refreshing token: " + e.getMessage());&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The refreshing apparently works (no errors, at least), but then the upload fails with a new error: invalid_access_token.&lt;/P&gt;
&lt;P&gt;So, should I create a new client with the refresh token or not? Am I refreshing the token correctly?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 13:31:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712103#M31537</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T13:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712116#M31540</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Take a look on a &lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Is-it-possible-to-get-a-permanent-token-for-uploading-files-to/td-p/712091" target="_blank" rel="noopener"&gt;nearby thread&lt;/A&gt;. It's almost the same (different languages, but the same idea).&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 13:56:36 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712116#M31540</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-09-07T13:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712117#M31541</link>
      <description>&lt;P&gt;[Cross-linking for reference: &lt;A href="https://stackoverflow.com/questions/77059304/dropbox-java-client-for-android-how-to-refresh-token" target="_blank"&gt;https://stackoverflow.com/questions/77059304/dropbox-java-client-for-android-how-to-refresh-token&lt;/A&gt; ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dropbox is no longer offering the option for creating new long-lived access tokens. Dropbox is now issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. You can find &lt;A href="https://dropbox.tech/developers/migrating-app-permissions-and-access-tokens#updating-access-token-type" target="_blank" rel="noopener noreferrer nofollow"&gt;more information on this migration here&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. Refresh tokens do not expire and can be store and re-used repeatedly. While you do need to use the OAuth app authorization flow to get a refresh token, this only needs to be done once per account. You can find more information in the &lt;A href="https://developers.dropbox.com/oauth-guide" target="_blank" rel="noopener noreferrer"&gt;OAuth Guide&lt;/A&gt; and &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#authorization" target="_blank" rel="noopener noreferrer"&gt;authorization documentation&lt;/A&gt;. There's a basic outline of processing this flow in &lt;A href="https://dropbox.tech/developers/using-oauth-2-0-with-offline-access" target="_blank" rel="noopener noreferrer nofollow"&gt;this blog post&lt;/A&gt; which may serve as a useful example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://github.com/dropbox/dropbox-sdk-java" rel="noopener noreferrer" target="_blank"&gt;official Dropbox Java SDK&lt;/A&gt; can actually handle the process for you automatically, as long as you supply the necessary credentials, e.g., as shown retrieved in &lt;A href="https://github.com/dropbox/dropbox-sdk-java/tree/main/examples/examples/src/main/java/com/dropbox/core/examples/authorize" rel="noopener noreferrer" target="_blank"&gt;the examples here&lt;/A&gt;. For instance, for a client-side app, such as a desktop app, you should use the PKCE flow, e.g., &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/main/examples/examples/src/main/java/com/dropbox/core/examples/authorize/PkceAuthorize.java" rel="noopener noreferrer" target="_blank"&gt;as shown here&lt;/A&gt;. That allows you to make and save &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/main/examples/examples/src/main/java/com/dropbox/core/examples/authorize/AuthorizeExample.kt#L85" rel="noopener noreferrer" target="_blank"&gt;a DbxCredential with a refresh token as shown here&lt;/A&gt;. With that, you can make API calls &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/main/examples/examples/src/main/java/com/dropbox/core/examples/account_info/AccountInfoExample.kt#L26" rel="noopener noreferrer" target="_blank"&gt;like shown here&lt;/A&gt;.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;For Android apps using the &lt;A href="https://github.com/dropbox/dropbox-sdk-java" rel="noopener noreferrer" target="_blank"&gt;official Dropbox Java SDK&lt;/A&gt;, you should use the updated authorization functionality, starting with the &lt;CODE&gt;startOAuth2PKCE&lt;/CODE&gt; method. You can find &lt;A href="https://github.com/dropbox/dropbox-sdk-java/tree/main/examples/android" rel="noopener noreferrer" target="_blank"&gt;an example app here&lt;/A&gt;. For instance, you can see &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/009c8eb3677f2a329bb43c7e2cb00df3f3d68aaf/examples/android/src/main/java/com/dropbox/core/examples/android/internal/api/DropboxOAuthUtil.kt#L52" rel="noopener noreferrer" target="_blank"&gt;where that starts in the code here&lt;/A&gt; and &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/009c8eb3677f2a329bb43c7e2cb00df3f3d68aaf/examples/android/src/main/java/com/dropbox/core/examples/android/internal/api/DropboxOAuthUtil.kt#L83" rel="noopener noreferrer" target="_blank"&gt;how the result is handled here&lt;/A&gt;. When you use that functionality as shown, the SDK will then handle the refresh process for you automatically.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 13:57:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712117#M31541</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-09-07T13:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712122#M31542</link>
      <description>&lt;P&gt;The problem is that I'm not using the HTTP API, I have to refer myself to the Java SDK API, and I don't understand how the possible HTTP messages should be "translated" to the API calls.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 14:08:17 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712122#M31542</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T14:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712124#M31543</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;The problem is that I'm not using the HTTP API, I have to refer myself to the Java SDK API, ...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You don't need to do much more than you already have done. You're using HTTP API actually, in spit not directly; That's what Dropbox SDKs are for (not only Java Dropbox SDK). &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt; Of course, you can manage the API calls directly, but you don't need to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;... I don't understand how the possible HTTP messages should be "translated" to the API calls.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;They should NOT!!! &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@D88F213CAFB196B6AB70612B08AD9D31/emoticons/1f601.png" alt=":beaming_face_with_smiling_eyes:" title=":beaming_face_with_smiling_eyes:" /&gt; All Dropbox API calls themselves are HTTP requests. SDK just hides this and make developer life easier. That's it.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 14:18:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712124#M31543</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-09-07T14:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712136#M31548</link>
      <description>&lt;P&gt;Hi Greg, many thanks for answering. I guess you're tired of answering (more or less) the same questions repeatedly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;Dropbox is no longer offering the option for creating new long-lived access tokens. (...)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sure I know, that's why my life is miserable. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. (...)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Great. I've already got this token through a call to the HTTP API, though I thought it was called "access token".&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;The &lt;A href="https://github.com/dropbox/dropbox-sdk-java" target="_blank" rel="noopener noreferrer nofollow"&gt;official Dropbox Java SDK&lt;/A&gt; can actually handle the process for you automatically, as long as you supply the necessary credentials, e.g., as shown retrieved in &lt;A href="https://github.com/dropbox/dropbox-sdk-java/tree/main/examples/examples/src/main/java/com/dropbox/core/examples/authorize" target="_blank" rel="noopener noreferrer nofollow"&gt;the examples here&lt;/A&gt;.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem with all these examples is that they trigger an oauth2 web page authorization which must be answered by the user, something I don't want.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;There's a basic outline of processing this flow in &lt;A href="https://dropbox.tech/developers/using-oauth-2-0-with-offline-access" target="_blank" rel="noopener noreferrer nofollow"&gt;this blog post&lt;/A&gt; which may serve as a useful example.&lt;/EM&gt;&lt;BR /&gt;&lt;STRONG&gt;The matter is how to these HTTP API calls should be translated to method calls in the Java SDK, something that is not detailed anywhere for my particular case.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;For Android apps using the &lt;A href="https://github.com/dropbox/dropbox-sdk-java" target="_blank" rel="noopener noreferrer nofollow"&gt;official Dropbox Java SDK&lt;/A&gt;, you should use the updated authorization functionality, starting with the startOAuth2PKCE method.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Okay, then should I forget about tokens and use this PKCE method? Just to be sure.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks again.&lt;BR /&gt;-- Baltasar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 14:50:47 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712136#M31548</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T14:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712139#M31549</link>
      <description>&lt;P&gt;Thanks for answering.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;You don't need to do much more than you already have done.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;It's unfortunate it is not working, though.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;They should NOT!!! &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@D88F213CAFB196B6AB70612B08AD9D31/emoticons/1f601.png" alt=":beaming_face_with_smiling_eyes:" title=":beaming_face_with_smiling_eyes:" /&gt; All Dropbox API calls themselves are HTTP requests. SDK just hides this and make developer life easier. That's it.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Sure. Let me rephrase my question. What objects of the SDK must I create and what methods should I called so the code works?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-- Baltasar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 14:53:29 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712139#M31549</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T14:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712140#M31550</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt;&amp;nbsp;Здравко is correct; the Dropbox SDKs, including the Dropbox Java SDK, themselves call the Dropbox HTTP API. You can certainly just use the Dropbox Java SDK though. The second half of my previous message contains links specific to the Dropbox Java SDK, so refer to those for information on how to use that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, to be clear, "access tokens" and "refresh tokens" are different types of tokens, and are not interchangeable. Refresh tokens can be used to programmatically retrieve more access tokens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to get a refresh token, it is necessary to authorize the app via the app authorization web page. This only needs to be done once per account though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Dropbox Java SDK implements the same functionality as documented for the HTTP API. You can use the SDK or the HTTP interface directly; either way is fine and that is up to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PKCE flow is recommended for client-side applications, such as Android apps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're implementing the authorization flow on Android, it is recommended that you use the startOAuth2PKCE functionality as shown in the example I linked. That functionality in the SDK will do most of the work for you. &lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 14:55:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712140#M31550</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-09-07T14:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712144#M31551</link>
      <description>&lt;P&gt;&amp;gt; &lt;EM&gt;the Dropbox SDKs, including the Dropbox Java SDK, themselves call the Dropbox HTTP API. You can certainly just use the Dropbox Java SDK...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I know that, I was simply noting that this does not help me to know the sequence of which classes and methods to call.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;The PKCE flow is recommended for client-side applications, such as Android apps. If you're implementing the authorization flow on Android, it is recommended that you use the startOAuth2PKCE functionality as shown in the example I linked. That functionality in the SDK will do most of the work for you.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Maybe I'm missing something big, but the app (Kotlin, not Java, but all right, I guess I'd be able to translate), does not contain a call to &lt;EM&gt;startOAuth2PKCE()&lt;/EM&gt; which I had been able to find.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'will try and pick up from here with PKCE. I'd like to note, however, that for a such important change in the API there is scarce info and documentation (many times obsolete), to follow, at least for the type of app (off-line) that I intend to write.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-- Baltasar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 15:15:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712144#M31551</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T15:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712158#M31552</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt; Thanks for the feedback!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The startOAuth2PKCE method is &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/d96bbd5c28b1d2398957931e0ca1e3568b2df41d/android/src/main/java/com/dropbox/core/android/Auth.kt#L69" target="_blank"&gt;defined here&lt;/A&gt;. If you're not seeing that method in your installation, please make sure you're using a recent version of the SDK. The latest version is currently &lt;A href="https://github.com/dropbox/dropbox-sdk-java/releases/tag/v5.4.5" target="_blank"&gt;v5.4.5&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, &lt;A href="https://github.com/dropbox/dropbox-sdk-java/tree/main/examples/android" target="_blank"&gt;the Android example here&lt;/A&gt; is written in Kotlin, e.g., see &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/009c8eb3677f2a329bb43c7e2cb00df3f3d68aaf/examples/android/src/main/java/com/dropbox/core/examples/android/internal/api/DropboxOAuthUtil.kt#L52" target="_blank"&gt;the DropboxOAuthUtil.kt file&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For reference the startOAuth2PKCE method does automatically request "offline" access, in order to get a refresh token.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 15:40:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712158#M31552</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-09-07T15:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712166#M31553</link>
      <description>&lt;P&gt;&amp;gt; &lt;EM&gt;&lt;A href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070" target="_blank"&gt;@baltasarq&lt;/A&gt; Thanks for the feedback!&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I found the code in the internal/ folder.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;The startOAuth2PKCE method is &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/d96bbd5c28b1d2398957931e0ca1e3568b2df41d/android/src/main/java/com/dropbox/core/android/Auth.kt#L69" target="_blank" rel="nofollow noopener noreferrer"&gt;defined here&lt;/A&gt;. If you're not seeing that method in your installation, please make sure you're using a recent version of the SDK. The latest version is currently &lt;A href="https://github.com/dropbox/dropbox-sdk-java/releases/tag/v5.4.5" target="_blank" rel="nofollow noopener noreferrer"&gt;v5.4.5&lt;/A&gt;.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Yep. But, I guess that this initial authorize is only needed once, right? Then I should be able to access with a single token...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-- Baltasar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 16:02:23 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712166#M31553</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T16:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712174#M31554</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbxCredential credentials = new DbxCredential(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_token ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Long.MAX_VALUE,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; result.getAccessToken(),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_key ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getString( R.string.dropbox_secret ) );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;client = new DbxClientV2( config, credentials );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt;, You can correct the above code in following way:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbxCredential credentials = new DbxCredential(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "", // Empty values here to force the initial refresh.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0, //&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; refreshToken,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; appKey,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; appSecret );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;client = new DbxClientV2( config, credentials );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Assign to &lt;FONT face="courier new,courier"&gt;refreshToken&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;appKey&lt;/FONT&gt;, and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;appSecret&lt;/FONT&gt; to the values according to the guide &lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Issue-in-generating-access-token/m-p/592921/highlight/true#M27586" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. So you wouldn't need to do anything OAuth related inside your application.&lt;/P&gt;&lt;P&gt;Hope this gives answer to your "main" question. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 16:22:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712174#M31554</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-09-07T16:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712207#M31555</link>
      <description>&lt;P&gt;&amp;gt; &lt;EM&gt;You can correct the above code in following way:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Done, thank you.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;EM&gt;Assign to refreshToken, appKey, and appSecret to the values according to the guide here. So you wouldn't need to do anything OAuth related inside your application. Hope this gives answer to your "main" question. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;It works!! But I have a side problem, for some reason, (probably because I entered the curl commands you linked in my computer's console), now my personal Dropbox is connected to the app, while I wanted another specific Dropbox to be linked... I'll probably have to unlink and start the process again, I guess converting all the curl commands to URL's.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Also, I want to check tomorrow whether it still works or something is still expiring, which would mean that I'd anyway have to refresh inside my code. Let's see.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;-- Baltasar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 18:01:01 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712207#M31555</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T18:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712209#M31556</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt; The account that gets connected is determined by which account you're signed in to in your browser when you authorize the app. If you want to use a different account, you'll need to switch to that account in your browser and process the authorization flow again.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 18:06:37 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712209#M31556</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-09-07T18:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712211#M31557</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; &lt;A href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070" target="_blank" rel="noopener"&gt;@baltasarq&lt;/A&gt; The account that gets connected is determined by which account you're signed in to in your browser when you authorize the app. If you want to use a different account, you'll need to switch to that account in your browser and process the authorization flow again.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Got it! Thanks, @Greg-DB and specially @&lt;SPAN class=""&gt;Здравко&lt;/SPAN&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Baltasar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 18:12:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712211#M31557</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-07T18:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712365#M31559</link>
      <description>&lt;P&gt;Okay, solved.&lt;/P&gt;&lt;P&gt;I summarized the process in the following notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Dropbox client API&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1Cloud backup with the Dropbox API&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Until september 2022, it was possible to generate an access token, use it when creating the client, and don’t worry again about authorization. This is not possible anymore, so in order to create a backup system the most similar access system is PKCE for an offline app.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2Refresh token&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;After creating the app in the &lt;I&gt;App Console&lt;/I&gt;, ignore the “generate token” option since this only creates a token valid for about 4 hours (though there is no note about this). Keep the PKCE activated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, paste the following line in the address bar of your browser:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;https://www.dropbox.com/oauth2/authorize?token_access_type=offline&amp;amp;response_type=code&amp;amp;client_id=&amp;lt;App key&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to substitute &lt;I&gt;&amp;lt;App Key&amp;gt;&lt;/I&gt; for the application key that appears in the &lt;I&gt;App Console&lt;/I&gt;&lt;SPAN&gt;. Keep the &lt;/SPAN&gt;&lt;I&gt;App Secret&lt;/I&gt;&lt;SPAN&gt; code near, as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You will authorize the app only once through that URL, and the answer will be the so called &lt;/SPAN&gt;&lt;EM&gt;authorization code&lt;/EM&gt;&lt;SPAN&gt;, an hexadecimal code. You need to take note of this code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3Obtaining the refresh token&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now you have to open a terminal and paste there:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;curl https://api.dropbox.com/oauth2/token -d code=&amp;lt;Authorization Code&amp;gt; -d grant_type=authorization_code -u &amp;lt;App key&amp;gt;:&amp;lt;App secret&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You have to substitute &lt;/SPAN&gt;&lt;I&gt;&amp;lt;Authorization Code&amp;gt;&lt;/I&gt;&lt;SPAN&gt; with the last obtained token, &lt;/SPAN&gt;&lt;I&gt;&amp;lt;App Key&amp;gt;&lt;/I&gt;&lt;SPAN&gt; with the App Key and &lt;/SPAN&gt;&lt;I&gt;&amp;lt;App Secret&amp;gt;&lt;/I&gt;&lt;SPAN&gt; with the App Secret, these latter appearing in the App Console.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The answer will be a JSON piece of data similar to the following one:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
    "access_token":"sl...",
    "token_type": "bearer",
    "expires_in": 14400,
    "refresh_token": "oDfT54975DfGh12345KlMnOpQrSt01a",
    "scope": "account_info.read files.content.read ...",
    "uid": "123...",
    "account_id": "dbid:AB..."
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The &lt;/SPAN&gt;&lt;I&gt;access token&lt;/I&gt;&lt;SPAN&gt; would be valid for the app to access Dropbox for 4 hours (&lt;/SPAN&gt;&lt;I&gt;expires_in&lt;/I&gt;&lt;SPAN&gt;). Note the “sl.” prefix (Short Lived). The important code here is &lt;/SPAN&gt;&lt;I&gt;refresh_token, w&lt;/I&gt;&lt;SPAN&gt;hich is a permanent token that you can access Dropbox with.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;4Using the Java API&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The problem with the API is that it is not always intuitive to use. With the PKCE access system, we only need to change the Dropbox client object in respect to what appears in the documentation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        &lt;STRONG&gt;final&lt;/STRONG&gt; &lt;STRONG&gt;String&lt;/STRONG&gt; APP_PACKAGE = OWNER.getPackageName();
        &lt;STRONG&gt;final&lt;/STRONG&gt; DbxRequestConfig CONFIG = DbxRequestConfig.newBuilder( APP_PACKAGE ).build();
        &lt;STRONG&gt;final&lt;/STRONG&gt; DbxCredential CREDENTIALS = &lt;STRONG&gt;new&lt;/STRONG&gt; DbxCredential(
                "",
                0L,
                &lt;I&gt;&amp;lt;&lt;/I&gt;&lt;I&gt;dropbox refresh token&amp;gt;&lt;/I&gt;,
                &lt;I&gt;&amp;lt;&lt;/I&gt;&lt;I&gt;app key&amp;gt;&lt;/I&gt;,
                &lt;I&gt;&amp;lt;&lt;/I&gt;&lt;I&gt;app secret&amp;gt;&lt;/I&gt; );

        &lt;STRONG&gt;this&lt;/STRONG&gt;.DBOX_CLIENT = &lt;STRONG&gt;new&lt;/STRONG&gt; DbxClientV2( this.CONFIG, CREDENTIALS );&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The remaining code is left untouched.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 11:07:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712365#M31559</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-08T11:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712372#M31561</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1743070"&gt;@baltasarq&lt;/a&gt;, Just a note: In your web browser you're receiving authorization code, not access token! They are different things. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 11:01:26 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712372#M31561</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-09-08T11:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712374#M31562</link>
      <description>&lt;P&gt;Thanks, corrected.&lt;/P&gt;&lt;P&gt;-- Baltasar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 11:05:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/712374#M31562</guid>
      <dc:creator>baltasarq</dc:creator>
      <dc:date>2023-09-08T11:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/771119#M33734</link>
      <description>&lt;P class=""&gt;I realize this post is a little old.&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;My problem was I needed to actually get a refreshed access token because I am doing this in multi-platform Kotlin, and have to keep the backup part more generic than using the android JDK’s (7.0), that will not work on the IOS side.&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;I spent a week or two trying to get it to actually get a new access token, and couldn't find the last step to make it work.&amp;nbsp; I thought I would share in case others might need it.&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;I added this method to &lt;SPAN class=""&gt;DropboxOAuthUtil&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;from the example (&lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/main/examples/android/src/main/java/com/dropbox/core/examples/android/internal/api/DropboxOAuthUtil.kt" target="_blank" rel="noopener"&gt;https://github.com/dropbox/dropbox-sdk-java/blob/main/examples/android/src/main/java/com/dropbox/core/examples/android/internal/api/DropboxOAuthUtil.kt&lt;/A&gt;)&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I call this refresh before performing the backup and restore in case the token expired.&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;// Dave Adding this&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;fun &lt;/SPAN&gt;&lt;SPAN&gt;refreshToken&lt;/SPAN&gt;(appKey: &lt;SPAN&gt;String&lt;/SPAN&gt;, refreshToken: &lt;SPAN&gt;String&lt;/SPAN&gt;, appSecret: &lt;SPAN&gt;String&lt;/SPAN&gt;): &lt;SPAN&gt;String &lt;/SPAN&gt;{&lt;BR /&gt;    &lt;SPAN&gt;val &lt;/SPAN&gt;&lt;SPAN&gt;requestConfig &lt;/SPAN&gt;= DbxRequestConfig(&lt;SPAN&gt;dropboxAppConfig&lt;/SPAN&gt;.&lt;SPAN&gt;clientIdentifier&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;val &lt;/SPAN&gt;&lt;SPAN&gt;dbCredential &lt;/SPAN&gt;= DbxCredential(&lt;SPAN&gt;""&lt;/SPAN&gt;, &lt;SPAN&gt;0L&lt;/SPAN&gt;, refreshToken, appKey, appSecret )&lt;BR /&gt;    &lt;SPAN&gt;dbCredential&lt;/SPAN&gt;.refresh(&lt;SPAN&gt;requestConfig&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;logMessage&lt;/SPAN&gt;.logDebug(&lt;SPAN&gt;TAG&lt;/SPAN&gt;, &lt;SPAN&gt;"refreshToken NEW?? dbCredential.accessToken=&lt;/SPAN&gt;&lt;SPAN&gt;${&lt;/SPAN&gt;&lt;SPAN&gt;dbCredential&lt;/SPAN&gt;.&lt;SPAN&gt;accessToken&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;&lt;SPAN&gt;dbCredential&lt;/SPAN&gt;.&lt;SPAN&gt;accessToken&lt;BR /&gt;&lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 May 2024 19:27:18 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/771119#M33734</guid>
      <dc:creator>Dave__K</dc:creator>
      <dc:date>2024-05-16T19:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox Java client for Android: how to refresh token?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/771121#M33735</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1837661"&gt;@Dave__K&lt;/a&gt;, reimplement the class &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/main/core/src/main/java/com/dropbox/core/oauth/DbxCredential.java" target="_blank" rel="noopener"&gt;here&lt;/A&gt; is you want to.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 19:43:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-Java-client-for-Android-how-to-refresh-token/m-p/771121#M33735</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2024-05-16T19:43:02Z</dc:date>
    </item>
  </channel>
</rss>

