从他们的 Java SDK 中,我像这样使用了他们的Upgrader类
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
}
它因相关性而被剪断,但如果您在 Android 中执行此操作,请确保您在内部执行此操作,AsyncTask
否则它会引发在主线程上执行工作的异常。