<?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 My migration plan for Android app (short-lived access tokens) in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/My-migration-plan-for-Android-app-short-lived-access-tokens/m-p/480095#M24223</link>
    <description>&lt;P&gt;In looking at the various examples of implementing short-lived tokens in Andriod, I wanted my implementation to use more primitive methods, instead of &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java" target="_self"&gt;DropboxClientFactory&lt;/A&gt;, PicassoClient, and &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DbxRequestConfigFactory.java" target="_self"&gt;DbxRequestConfigFactory&lt;/A&gt;. So here is what I have done, trying to pattern my code after the code in &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java" target="_self"&gt;DropboxActivity&lt;/A&gt;, and adapting it to my existing code for the long-lived access tokens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first thing I noticed is that I cannot follow the pattern of having one block of code for USE_SLT true and another block of code for USE_SLT false, as shown in &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java" target="_self"&gt;DropboxActivity&lt;/A&gt;. I need to be able to create a DBClientV2 from the old long-lived token, if it exists, and from a new short-lived token, if not. So the onResume method in my activity that uses Dropbox contains:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#660e7a"&gt;&lt;STRONG&gt;requestConfig &lt;/STRONG&gt;&lt;/FONT&gt;= DbxRequestConfig.&lt;I&gt;newBuilder&lt;/I&gt;(&lt;FONT color="#008000"&gt;&lt;STRONG&gt;"TuneLab Tuning Files 2.6"&lt;/STRONG&gt;&lt;/FONT&gt;).build();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxCredential credential = &lt;FONT color="#000080"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;(&lt;FONT color="#660e7a"&gt;&lt;I&gt;sDbxClient &lt;/I&gt;&lt;/FONT&gt;== &lt;FONT color="#000080"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;) {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;String accessToken = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;prefs&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.getString(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;DBaccesstokenKEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;);  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..old-style long-lived&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;String serializedCredential = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;prefs&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.getString(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;DBcredentialKEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;);  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..new-style&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#808080"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..At most one of the two Strings above will ever be non-null&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(accessToken != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..first try the long-lived token&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;sDbxClient &lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxClientV2(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;requestConfig&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, accessToken);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;else &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;{  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..no long-lived token.  Try for a short-lived token.&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(serializedCredential != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..check if short-lived already credential exists&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;try &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;{  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..expand the String to a DbxCredential object&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;credential = DbxCredential.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;Reader&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.readFully(serializedCredential);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;catch &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(Throwable t) {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;nullOutDBaccessToken&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;();  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..nulls both SharedPreferences above&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;else if &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;authWasJustAttempted&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..set by a button listener for "Link to Dropbox"&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;authWasJustAttempted &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;;  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..so we don't come here again&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;credential = Auth.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;getDbxCredential&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;();  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..will be null if user said NO&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(credential != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..either from serialized version, or from Auth attempt&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;credential = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxCredential(credential.getAccessToken(), -&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;1L&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, credential.getRefreshToken(), credential.getAppKey());&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(credential != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;sDbxClient &lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxClientV2(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;requestConfig&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, credential);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;prefs&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.edit().putString(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;DBcredentialKEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, credential.toString()).apply();  //..necessary????&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;If sDbxClient is null after onResume, the activity presents the user with only one option, which is to link to Dropbox. If sDbxClient is not null, that means either an existing long-lived or short-lived access token was in effect, or this activity has just resumed after a successful Auth flow where the user said “yes”. The reference to requestConfig is to a private member of this activity that is referenced in onResume and in a button listener when the user chooses to establish a new link to Dropbox. If the user taps that button, authWasJustAttempted is set to true upon launching the Auth attempt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;List&amp;lt;String&amp;gt; scope = &lt;FONT color="#000080"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;ArrayList&amp;lt;&amp;gt;(Arrays.&lt;I&gt;asList&lt;/I&gt;(&lt;FONT color="#008000"&gt;&lt;STRONG&gt;"files.content.write"&lt;/STRONG&gt;&lt;/FONT&gt;, &lt;FONT color="#008000"&gt;&lt;STRONG&gt;"files.content.read"&lt;/STRONG&gt;&lt;/FONT&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;Auth.&lt;I&gt;startOAuth2PKCE&lt;/I&gt;(getApplicationContext(), getString(R.string.&lt;FONT color="#660e7a"&gt;&lt;I&gt;&lt;STRONG&gt;APP_KEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;), &lt;FONT color="#660e7a"&gt;&lt;STRONG&gt;requestConfig&lt;/STRONG&gt;&lt;/FONT&gt;, scope);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#660e7a"&gt;&lt;STRONG&gt;authWasJustAttempted &lt;/STRONG&gt;&lt;/FONT&gt;= &lt;FONT color="#000080"&gt;&lt;STRONG&gt;true&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;It seems that the call shown in onResume to&lt;/P&gt;
&lt;PRE&gt;credential = &lt;SPAN&gt;new &lt;/SPAN&gt;DbxCredential(credential.getAccessToken(), -&lt;SPAN&gt;1L&lt;/SPAN&gt;, credential.getRefreshToken(), credential.getAppKey());&lt;/PRE&gt;
&lt;P&gt;accomplises the refreshing of the short-lived access token in credential, and so credential is changed from what it was after the readFully of the serialized version. If it is changed, then shouldn't the serialized version be updated in SharedPreferences too? I didn't see that in any of the examples, so I am confused as to whether or not it is necessary. What would happen if the token got refreshed, but the next time we come to this Activity, we try to refresh it again, but starting with a very stale version of the DbxCredential? Would it work anyway?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than these changes to my old code, the rest of my app would operate as before, using sDbxClient just as it was used before in uploading and downloading files. Finally, the scope that I think I need is just "files.content.write", "files.content.read" because all my app does is upload files to the App Folder or download files from the App Folder. I also examine the metadata for files to determine their last modified date. Does that require an additional scope, or are the two listed sufficient?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2020 19:40:23 GMT</pubDate>
    <dc:creator>Robert S.138</dc:creator>
    <dc:date>2020-12-17T19:40:23Z</dc:date>
    <item>
      <title>My migration plan for Android app (short-lived access tokens)</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/My-migration-plan-for-Android-app-short-lived-access-tokens/m-p/480095#M24223</link>
      <description>&lt;P&gt;In looking at the various examples of implementing short-lived tokens in Andriod, I wanted my implementation to use more primitive methods, instead of &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java" target="_self"&gt;DropboxClientFactory&lt;/A&gt;, PicassoClient, and &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DbxRequestConfigFactory.java" target="_self"&gt;DbxRequestConfigFactory&lt;/A&gt;. So here is what I have done, trying to pattern my code after the code in &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java" target="_self"&gt;DropboxActivity&lt;/A&gt;, and adapting it to my existing code for the long-lived access tokens.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first thing I noticed is that I cannot follow the pattern of having one block of code for USE_SLT true and another block of code for USE_SLT false, as shown in &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java" target="_self"&gt;DropboxActivity&lt;/A&gt;. I need to be able to create a DBClientV2 from the old long-lived token, if it exists, and from a new short-lived token, if not. So the onResume method in my activity that uses Dropbox contains:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#660e7a"&gt;&lt;STRONG&gt;requestConfig &lt;/STRONG&gt;&lt;/FONT&gt;= DbxRequestConfig.&lt;I&gt;newBuilder&lt;/I&gt;(&lt;FONT color="#008000"&gt;&lt;STRONG&gt;"TuneLab Tuning Files 2.6"&lt;/STRONG&gt;&lt;/FONT&gt;).build();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxCredential credential = &lt;FONT color="#000080"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;(&lt;FONT color="#660e7a"&gt;&lt;I&gt;sDbxClient &lt;/I&gt;&lt;/FONT&gt;== &lt;FONT color="#000080"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;) {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;String accessToken = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;prefs&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.getString(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;DBaccesstokenKEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;);  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..old-style long-lived&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;String serializedCredential = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;prefs&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.getString(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;DBcredentialKEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;);  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..new-style&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#808080"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..At most one of the two Strings above will ever be non-null&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(accessToken != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..first try the long-lived token&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;sDbxClient &lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxClientV2(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;requestConfig&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, accessToken);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;else &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;{  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..no long-lived token.  Try for a short-lived token.&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(serializedCredential != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..check if short-lived already credential exists&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;try &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;{  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..expand the String to a DbxCredential object&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;credential = DbxCredential.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;Reader&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.readFully(serializedCredential);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;catch &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(Throwable t) {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;nullOutDBaccessToken&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;();  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..nulls both SharedPreferences above&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;} &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;else if &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;authWasJustAttempted&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..set by a button listener for "Link to Dropbox"&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;authWasJustAttempted &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;;  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..so we don't come here again&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;credential = Auth.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;getDbxCredential&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;();  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..will be null if user said NO&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(credential != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {  &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#808080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;//..either from serialized version, or from Auth attempt&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;credential = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxCredential(credential.getAccessToken(), -&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;1L&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, credential.getRefreshToken(), credential.getAppKey());&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;(credential != &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;null&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;) {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;sDbxClient &lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;DbxClientV2(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;requestConfig&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, credential);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;            &lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;prefs&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;.edit().putString(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#660e7a"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;I&gt;&lt;STRONG&gt;DBcredentialKEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;, credential.toString()).apply();  //..necessary????&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;         &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;      &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;   &lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;If sDbxClient is null after onResume, the activity presents the user with only one option, which is to link to Dropbox. If sDbxClient is not null, that means either an existing long-lived or short-lived access token was in effect, or this activity has just resumed after a successful Auth flow where the user said “yes”. The reference to requestConfig is to a private member of this activity that is referenced in onResume and in a button listener when the user chooses to establish a new link to Dropbox. If the user taps that button, authWasJustAttempted is set to true upon launching the Auth attempt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;List&amp;lt;String&amp;gt; scope = &lt;FONT color="#000080"&gt;&lt;STRONG&gt;new &lt;/STRONG&gt;&lt;/FONT&gt;ArrayList&amp;lt;&amp;gt;(Arrays.&lt;I&gt;asList&lt;/I&gt;(&lt;FONT color="#008000"&gt;&lt;STRONG&gt;"files.content.write"&lt;/STRONG&gt;&lt;/FONT&gt;, &lt;FONT color="#008000"&gt;&lt;STRONG&gt;"files.content.read"&lt;/STRONG&gt;&lt;/FONT&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;Auth.&lt;I&gt;startOAuth2PKCE&lt;/I&gt;(getApplicationContext(), getString(R.string.&lt;FONT color="#660e7a"&gt;&lt;I&gt;&lt;STRONG&gt;APP_KEY&lt;/STRONG&gt;&lt;/I&gt;&lt;/FONT&gt;), &lt;FONT color="#660e7a"&gt;&lt;STRONG&gt;requestConfig&lt;/STRONG&gt;&lt;/FONT&gt;, scope);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#660e7a"&gt;&lt;STRONG&gt;authWasJustAttempted &lt;/STRONG&gt;&lt;/FONT&gt;= &lt;FONT color="#000080"&gt;&lt;STRONG&gt;true&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;It seems that the call shown in onResume to&lt;/P&gt;
&lt;PRE&gt;credential = &lt;SPAN&gt;new &lt;/SPAN&gt;DbxCredential(credential.getAccessToken(), -&lt;SPAN&gt;1L&lt;/SPAN&gt;, credential.getRefreshToken(), credential.getAppKey());&lt;/PRE&gt;
&lt;P&gt;accomplises the refreshing of the short-lived access token in credential, and so credential is changed from what it was after the readFully of the serialized version. If it is changed, then shouldn't the serialized version be updated in SharedPreferences too? I didn't see that in any of the examples, so I am confused as to whether or not it is necessary. What would happen if the token got refreshed, but the next time we come to this Activity, we try to refresh it again, but starting with a very stale version of the DbxCredential? Would it work anyway?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than these changes to my old code, the rest of my app would operate as before, using sDbxClient just as it was used before in uploading and downloading files. Finally, the scope that I think I need is just "files.content.write", "files.content.read" because all my app does is upload files to the App Folder or download files from the App Folder. I also examine the metadata for files to determine their last modified date. Does that require an additional scope, or are the two listed sufficient?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 19:40:23 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/My-migration-plan-for-Android-app-short-lived-access-tokens/m-p/480095#M24223</guid>
      <dc:creator>Robert S.138</dc:creator>
      <dc:date>2020-12-17T19:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: My migration plan for Android app (short-lived access tokens)</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/My-migration-plan-for-Android-app-short-lived-access-tokens/m-p/480271#M24227</link>
      <description>&lt;BLOCKQUOTE&gt;If it is changed, then shouldn't the serialized version be updated in SharedPreferences too? I didn't see that in any of the examples, so I am confused as to whether or not it is necessary. What would happen if the token got refreshed, but the next time we come to this Activity, we try to refresh it again, but starting with a very stale version of the DbxCredential? Would it work anyway?&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The short-lived access token itself is very short-lived (just four hours) and doesn't need to be persisted to preferences each time. It's only the refresh token (and app key) that matters. The app doesn't need a short-lived access token to perform the refresh to get a new short-lived access token. Even if the previous short-lived access token is very old, the SDK can still perform the refresh successfully. The refresh token itself does not actually expire (unless the user or app revokes it).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Finally, the scope that I think I need is just "files.content.write", "files.content.read" because all my app does is upload files to the App Folder or download files from the App Folder. I also examine the metadata for files to determine their last modified date. Does that require an additional scope, or are the two listed sufficient?&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, if you just need to upload and download files, those scopes are sufficient. (Those scopes also actually depend on the "files.metadata.read" scope, so you'll automatically get that too, for reading the corresponding metadata.)&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 16:11:06 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/My-migration-plan-for-Android-app-short-lived-access-tokens/m-p/480271#M24227</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-12-17T16:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: My migration plan for Android app (short-lived access tokens)</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/My-migration-plan-for-Android-app-short-lived-access-tokens/m-p/480652#M24255</link>
      <description>&lt;P&gt;By the way,&amp;nbsp; I tried to run this code without making any changes in the App Console, and the&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Consolas, monospace"&gt;&lt;FONT size="2"&gt;Auth.&lt;I&gt;startOAuth2PKCE&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;produced an error 400 in the browser.&amp;nbsp; But after I went to my App Console and clicked "Migrate" (leaving all the permissions the same), then the Auth worked fine and my app works fine.&amp;nbsp; So you really do have to make that change in the app console for any of the new Auth method to work.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 22:27:14 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/My-migration-plan-for-Android-app-short-lived-access-tokens/m-p/480652#M24255</guid>
      <dc:creator>Robert S.138</dc:creator>
      <dc:date>2020-12-18T22:27:14Z</dc:date>
    </item>
  </channel>
</rss>

