本文整理汇总了Java中com.dropbox.core.android.Auth.getOAuth2Token方法的典型用法代码示例。如果您正苦于以下问题:Java Auth.getOAuth2Token方法的具体用法?Java Auth.getOAuth2Token怎么用?Java Auth.getOAuth2Token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.dropbox.core.android.Auth
的用法示例。
在下文中一共展示了Auth.getOAuth2Token方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finishAuthentication
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public boolean finishAuthentication() {
if (dbxClient == null && tryLinking) {
String accessToken = loadToken();
if (accessToken == null) {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
saveToken(accessToken);
}
}
if (accessToken != null) {
dbxClient = getDbxClient(accessToken);
return true;
}
}
return false;
}
示例2: authentication
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@Override
public boolean authentication() {
String accessToken = PreferencesUtil.getInstance().getDropboxAccessToken();
if (TextUtils.isEmpty(accessToken)) {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
PreferencesUtil.getInstance().setDropboxAccessToken(accessToken);
initData(accessToken);
return true;
}
} else {
initData(accessToken);
return true;
}
return false;
}
示例3: onResume
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
SharedPreferences prefs = getSharedPreferences("dropbox-sample", MODE_PRIVATE);
String accessToken = prefs.getString("access-token", null);
if (accessToken == null) {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
prefs.edit().putString("access-token", accessToken).apply();
initAndLoadData(accessToken);
}
} else {
initAndLoadData(accessToken);
}
String uid = Auth.getUid();
String storedUid = prefs.getString("user-id", null);
if (uid != null && !uid.equals(storedUid)) {
prefs.edit().putString("user-id", uid).apply();
}
}
示例4: resumeGetAuthToken
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
private void resumeGetAuthToken(FileStorageSetupActivity activity) {
FileStorageSetupActivity storageSetupAct = activity;
if (storageSetupAct.getState().containsKey("hasStartedAuth")) {
Log.d("KP2AJ", "auth started");
String v2Token = Auth.getOAuth2Token();
if (v2Token != null) {
Log.d("KP2AJ", "auth successful");
try {
storeKey(v2Token);
buildSession();
finishActivityWithSuccess(activity);
return;
} catch (Exception e) {
Log.d("KP2AJ", "finish with error: " + e.toString());
finishWithError(activity, e);
return;
}
}
Log.i(TAG, "authenticating not succesful");
Intent data = new Intent();
data.putExtra(EXTRA_ERROR_MESSAGE, "authenticating not succesful");
((Activity) activity).setResult(Activity.RESULT_CANCELED, data);
((Activity) activity).finish();
} else {
Log.d("KP2AJ", "Starting auth");
Auth.startOAuth2Authentication((Activity) activity, appInfo.getKey());
storageSetupAct.getState().putBoolean("hasStartedAuth", true);
}
}
示例5: onResume
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume() called");
String accessToken = Auth.getOAuth2Token(); //generate Access Token
Log.d(TAG, "onResume: accessToken = " + accessToken);
if (accessToken != null) {
//Store accessToken in SharedPreferences
Prefs.saveToPrefs(getApplicationContext(), "accessToken", accessToken);
parent.setVisibility(View.VISIBLE);
String backupDate = Prefs.getString(getApplicationContext(), "backup_date", "no");
if (!backupDate.equals("no")) {
textViewLastBackup.setText("Last backup: " + DateUtils.getFullTime(Long.valueOf(backupDate)));
textViewLastBackupStatus.setText("Click to back up anytime");
} else {
textViewLastBackup.setText("Click to backup");
textViewLastBackupStatus.setText("Your data will be backed up on Dropbox");
}
String restoredDate = Prefs.getString(getApplicationContext(), "restoredDate", "no");
if (!restoredDate.equals("no")) {
textViewLastRestored.setText("Last restored: " + DateUtils.getFullTime(Long.valueOf(restoredDate)));
textViewLastRestoredStatus.setText("Click to restore anytime");
} else {
textViewLastRestored.setText("Click to restore");
textViewLastRestoredStatus.setText("Your data will be restored from Dropbox");
}
buttonAuth.setVisibility(View.GONE);
} else {
accessToken = Prefs.getString(getApplicationContext(), "accessToken", "no");
if (accessToken.equals("no")) {
parent.setVisibility(View.GONE);
buttonAuth.setVisibility(View.VISIBLE);
}
}
}
示例6: completeAuth
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public void completeAuth() {
try {
String authToken = Auth.getOAuth2Token();
if (startedAuth && authToken != null) {
try {
MyPreferences.storeDropboxKeys(context, authToken);
} catch (IllegalStateException e) {
Log.i("Financisto", "Error authenticating Dropbox", e);
}
}
} finally {
startedAuth = false;
}
}
示例7: getAuthenticationToken
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
private String getAuthenticationToken() {
String accessToken = this.settings.getDropboxAccessToken();
if (accessToken == null) {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
this.settings.setDropboxAccessToken(accessToken);
}
}
return accessToken;
}
示例8: finishAuth
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
/**
* finish the authentication process. Must be called in the
* onResume method of the caller. See {@link ch.derlin.mybooks.views.StartActivity}
* for an example.
*/
public void finishAuth() {
String accessToken = Auth.getOAuth2Token(); //generate Access Token
if (accessToken != null) {
//Store accessToken in SharedPreferences
storeAccessToken(accessToken);
initializeClient(accessToken);
} else {
Log.i("DbAuthLog", "Error authenticating");
}
}
示例9: storeDropboxAccessToken
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
/**
* Stores a user access token generated from Dropbox's servers into SharedPreferences,
* if the user has authenticated their account and an access token has not already been stored.
* <p>
* Otherwise, SharedPreferences will not be modified.
* </p>
*/
private void storeDropboxAccessToken() {
if (!(AppPreferences.dropboxAccessTokenExists(this))) {
String accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
SharedPreferences preferences = getSharedPreferences(
AppPreferences.PREFERENCES_FILE_NAME, MODE_PRIVATE);
preferences.edit().putString(
AppPreferences.DROPBOX_ACCESS_TOKEN, accessToken).apply();
}
}
}
示例10: getToken
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
public static String getToken(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String accessToken = prefs.getString("dropbox-access-token", null);
if (accessToken != null) {
return accessToken;
}
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
prefs.edit().putString("dropbox-access-token", accessToken).commit();
}
return accessToken;
}
示例11: getSavedAccessToken
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
private String getSavedAccessToken(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String accessToken = prefs.getString(PREF_DROPBOX_TOKEN, null);
if (accessToken == null) {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
saveToken(context, accessToken);
}
}
return accessToken;
}
示例12: onRestart
import com.dropbox.core.android.Auth; //导入方法依赖的package包/类
@Override
protected void onRestart() {
super.onRestart();
final String token = Auth.getOAuth2Token();
if (token != null && !preferences.contains(DropboxSyncController.ACCESS_TOKEN))
preferences.edit().putString(DropboxSyncController.ACCESS_TOKEN, token).apply();
setResult(Activity.RESULT_OK);
finish();
}