Just for people stumbling upon this, the API for this is now there: https://www.dropbox.com/developers/core/docs#oa2-from-oa1
How to migrate OAuth1 token/secret pairs to OAuth2 access tokens for the Dropbox API?
Question
If a user has already authorized our app for OAuth 1 (so we have a valid token/secret pair for this user), is it possible to get a valid OAuth 2.0 access token without the user having to explicitly re-authorize our app again? I know that some APIs support this (e.g. Soundcloud and I think also Google), but I haven't found anything related to OAuth token migration in the Dropbox API documentation.
Context: We have an application in Java that accesses the Dropbox API with OAuth 1.0a using the Scribe OAuth library and want to migrate to the official Dropbox Java API that only supports OAuth 2 (and we don't want to have all our users having to re-authorize us).
Solution
OTHER TIPS
From their Java SDK, I used their Upgrader class like so
DbxOAuth1Upgrader upgrader;
DbxOAuth1AccessToken oAuth1AccessToken;
try {
DbxRequestConfig requestConfig = new DbxRequestConfig("Your App", Locale.getDefault().toString());
DbxAppInfo appInfo = new DbxAppInfo(DROPBOX_APP_KEY, DROPBOX_APP_SECRET);
upgrader = new DbxOAuth1Upgrader(requestConfig, appInfo);
oAuth1AccessToken = new DbxOAuth1AccessToken(oauth1AccessKey, oauth1AccessSecret);
String newToken = upgrader.createOAuth2AccessToken(oAuth1AccessToken);
upgrader.disableOAuth1AccessToken(oAuth1AccessToken);
return newToken;
} catch (Exception e) {
//deal with it
}
It's snipped for relevance but if you're doing this in Android, make sure you do it inside an AsyncTask
otherwise it throws an exception for performing work on the main thread.
See also the answer on the Dropbox forum: https://forums.dropbox.com/topic.php?id=107766. For now, there's no automated way today to do this migration.