Hi All,
So I've successfully migrated my Android app to Dbx API v2 (hooray!) but there's one bit missing. I need to tranfer previous APIv1 authentication to APIv2 otherwise everyone will be forced to re-authenticate, which is annoying.
Looking online, I've seen various guides that look simple but they all reference AndroidAuthSession which is a APIv1 call (com.dropbox.client2.android.AndroidAuthSession). So I don't understand how I do this in APIv2 or is that the point - we have to use old API1 calls to get the old tokens and then migrate them into APIv2? :thinking:
A summary of one example I found is below...
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();
}
Many thanks,
M.