<?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 Re: How to migrate previous API v1 authentication to APIv2? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/208090#M10218</link>
    <description>&lt;P&gt;Thanks dude, that worked!&amp;nbsp;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@AEF569BFDD1DD3EB9180949D237CD92A/images/emoticons/1f600.png" alt=":grinning:" title=":grinning:" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Feb 2017 22:43:22 GMT</pubDate>
    <dc:creator>MateusP</dc:creator>
    <dc:date>2017-02-22T22:43:22Z</dc:date>
    <item>
      <title>How to migrate previous API v1 authentication to APIv2?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/207893#M10201</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I've successfully migrated my Android app to Dbx API v2 (hooray!) but there's one bit missing. &amp;nbsp;I need to tranfer previous APIv1 authentication to APIv2 otherwise everyone will be forced to re-authenticate, which is annoying.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking online, I've seen various guides that look simple but they all reference&amp;nbsp;&lt;EM&gt;AndroidAuthSession&lt;/EM&gt; which is a APIv1 call (&lt;EM&gt;com.dropbox.client2.android.AndroidAuthSession&lt;/EM&gt;). &amp;nbsp;So I don't understand&amp;nbsp;how I do this in APIv2&amp;nbsp;or&amp;nbsp;is that the point - we have to use old API1 calls to get the old tokens and then migrate them into APIv2?&amp;nbsp;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@86FF27E33EE6AE58E01795BD66324A7F/images/emoticons/1f914.png" alt=":thinking:" title=":thinking:" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A summary of one example I found is below...&lt;/P&gt;
&lt;PRE&gt;String allTokens = getApplicationContext().getSharedPreferences("dropbox-credentials", Context.MODE_PRIVATE).getString("accounts", null);
...
JSONArray jsonAccounts = new JSONArray(allTokens);
tmpToken = jsonAccounts.getJSONObject(0).getString("userToken");
...
if (tmpToken.startsWith("|oa2|")) token = tmpToken.substring(5);
...
if (token.trim().length() == 0) {
  Auth.startOAuth2Authentication(this, APP_KEY);
} else { 
  AppKeyPair appKeyPair = new AppKeyPair(APP_KEY, APP_SECRET);
  AndroidAuthSession session = new AndroidAuthSession(appKeyPair);
  session.setOAuth2AccessToken(token);
  session.finishAuthentication();
}&lt;/PRE&gt;
&lt;P&gt;Many thanks,&lt;/P&gt;
&lt;P&gt;M.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:25:36 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/207893#M10201</guid>
      <dc:creator>MateusP</dc:creator>
      <dc:date>2019-05-29T09:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to migrate previous API v1 authentication to APIv2?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/207897#M10202</link>
      <description>&lt;P&gt;Exactly how this works will depend on what SDK and SDK version you were using for API v1, if any.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g., if you were using the &lt;A href="https://www.dropbox.com/developers-v1/core/start/android" target="_self"&gt;Android Core SDK&lt;/A&gt;, you likely have OAuth 2 access tokens. The SDK itself didn't handle access token storage for you, but most developers store them in&amp;nbsp;SharedPreferences.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as you're using the full&amp;nbsp;Dropbox or app folder permission, you can use the same OAuth 2 access tokens with API v2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like the v1 SDK, the v2 SDK leaves access token storage up to you, so you would just need to retrieve the existing&amp;nbsp;access tokens from storage and plug them in to get a v2 client as shown &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java#L21" target="_self"&gt;in the Android example here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 23:31:29 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/207897#M10202</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-02-21T23:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to migrate previous API v1 authentication to APIv2?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/208008#M10210</link>
      <description>&lt;P&gt;Thanks Greg, sounds simple.&amp;nbsp; I was using OAuth2 and storing the token in SharedPrefs with API v1 (see below)&lt;/P&gt;
&lt;PRE&gt;String access_token = session.getOAuth2AccessToken();
SharedPreferences prefs = getSharedPreferences(DROPBOX_PREFS, MODE_PRIVATE);
prefs.edit.putString(DROPBOX_PREFS_KEY, "oauth2:").commit();
prefs.edit.putString(DROPBOX_PREFS_SECRET, access_token).commit();
&lt;/PRE&gt;
&lt;P&gt;and in API v2 I'm using...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;String access_token = Auth.getOAuth2Token();&lt;BR /&gt;SharedPreferences prefs = getSharedPreferences(DROPBOX_PREFS, MODE_PRIVATE);
prefs.edit().putString(DROPBOX_PREFS_TOKEN, access_token).apply();&lt;/PRE&gt;
&lt;P&gt;So to get the token from API v1, I should be able to simply use the following .ine below?&amp;nbsp; Sorry I'm getting a bit confused - is the APIv1 "secret" the same as APIv2 "token"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;String api1_token = prefs.getString(DROPBOX_PREFS_SECRET, null);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks,&lt;/P&gt;
&lt;P&gt;M.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 16:57:37 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/208008#M10210</guid>
      <dc:creator>MateusP</dc:creator>
      <dc:date>2017-02-22T16:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to migrate previous API v1 authentication to APIv2?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/208040#M10215</link>
      <description>Yes, OAuth 2 access tokens only have one piece. That is, each OAuth 2 access token is just one long string. &lt;BR /&gt;&lt;BR /&gt;In your API v1 code, you're storing that via the access_token variable under DROPBOX_PREFS_SECRET.&lt;BR /&gt;&lt;BR /&gt;In your API v2 code, you're storing that via the access_token variable under DROPBOX_PREFS_TOKEN.&lt;BR /&gt;&lt;BR /&gt;(Part of the confusion may be that API v1 supported both OAuth 1 and OAuth 2. OAuth 1 access tokens are comprised of two pieces, a key and secret. API v2 only supports OAuth 2. OAuth 2 access tokens only have the one piece.)</description>
      <pubDate>Wed, 22 Feb 2017 19:34:32 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/208040#M10215</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-02-22T19:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to migrate previous API v1 authentication to APIv2?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/208090#M10218</link>
      <description>&lt;P&gt;Thanks dude, that worked!&amp;nbsp;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@AEF569BFDD1DD3EB9180949D237CD92A/images/emoticons/1f600.png" alt=":grinning:" title=":grinning:" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 22:43:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-migrate-previous-API-v1-authentication-to-APIv2/m-p/208090#M10218</guid>
      <dc:creator>MateusP</dc:creator>
      <dc:date>2017-02-22T22:43:22Z</dc:date>
    </item>
  </channel>
</rss>

