com.dropbox.client2.android.AndroidAuthSession Java Examples
The following examples show how to use
com.dropbox.client2.android.AndroidAuthSession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DropboxSyncService.java From narrate-android with Apache License 2.0 | 6 votes |
private void initialize(String token) { LogUtil.log(getClass().getSimpleName(), "initialize()"); AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET); AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE); mDBApi = new DropboxAPI<>(session); if ( token == null ) token = Settings.getDropboxSyncToken(); if ( token != null ) mDBApi.getSession().setOAuth2AccessToken(token); if (!doesFolderExist(getBaseFilePath())) { try { createFileStructure(); } catch (DropboxException e) { e.printStackTrace(); } } }
Example #2
Source File: MainOldActivity.java From android-auto-call-recorder with MIT License | 5 votes |
/** * Shows keeping the access keys returned from Trusted Authenticator in a local * store, rather than storing user name & password, and re-authenticating each * time (which is not to be done, ever). */ private void loadAuth(AndroidAuthSession session) { SharedPreferences prefs = getSharedPreferences(ACCOUNT_PREFS_NAME, 0); String key = prefs.getString(ACCESS_KEY_NAME, null); String secret = prefs.getString(ACCESS_SECRET_NAME, null); if (key == null || secret == null || key.length() == 0 || secret.length() == 0) return; if (key.equals("oauth2:")) { // If the key is set to "oauth2:", then we can assume the token is for OAuth 2. session.setOAuth2AccessToken(secret); } else { // Still support using old OAuth 1 tokens. session.setAccessTokenPair(new AccessTokenPair(key, secret)); } }
Example #3
Source File: MainOldActivity.java From android-auto-call-recorder with MIT License | 5 votes |
private AndroidAuthSession buildSession() { AppKeyPair appKeyPair = new AppKeyPair(DROPBOX_APP_KEY, DROPBOX_APP_SECRET); AndroidAuthSession session = new AndroidAuthSession(appKeyPair); loadAuth(session); return session; }
Example #4
Source File: DropBoxHelper.java From android-auto-call-recorder with MIT License | 5 votes |
private AndroidAuthSession buildSession() { AppKeyPair appKeyPair = new AppKeyPair(DROPBOX_APP_KEY, DROPBOX_APP_SECRET); AndroidAuthSession session = new AndroidAuthSession(appKeyPair); loadAuth(session); return session; }
Example #5
Source File: DropBoxHelper.java From android-auto-call-recorder with MIT License | 5 votes |
/** * Shows keeping the access keys returned from Trusted Authenticator in a local * store, rather than storing user name & password, and re-authenticating each * time (which is not to be done, ever). */ private void loadAuth(AndroidAuthSession session) { SharedPreferences prefs = mContext.getSharedPreferences(ACCOUNT_PREFS_NAME, 0); String key = prefs.getString(ACCESS_KEY_NAME, null); String secret = prefs.getString(ACCESS_SECRET_NAME, null); if (key == null || secret == null || key.length() == 0 || secret.length() == 0) return; if (key.equals("oauth2:")) { // If the key is set to "oauth2:", then we can assume the token is for OAuth 2. session.setOAuth2AccessToken(secret); } else { // Still support using old OAuth 1 tokens. session.setAccessTokenPair(new AccessTokenPair(key, secret)); } }
Example #6
Source File: MainOldActivity.java From android-auto-call-recorder with MIT License | 4 votes |
@Override protected void onResume() { super.onResume(); Log.d(TAG, "onResume()"); if (mDrawerLayout != null) { mDrawerLayout.addDrawerListener(mActionBarDrawerToggle); Log.d(TAG, "addingListener"); } nvDrawer.getMenu().findItem(R.id.navigation_fragment_home).setChecked(true); if (mActionBarDrawerToggle != null) { mActionBarDrawerToggle.syncState(); } if (mSwitch_auto_rec != null) { mSwitch_auto_rec.setChecked(mPreferenceHelper.canAutoRecord()); Log.d(TAG, "switch state | auto record = " + mSwitch_auto_rec.isChecked()); } if (mSwitch_auto_upload_on_DropBox != null) { mSwitch_auto_upload_on_DropBox.setChecked(mPreferenceHelper.canUploadOnDropBox()); Log.d(TAG, "switch state = | auto upload on dropbox " + mSwitch_auto_upload_on_DropBox.isChecked()); } //loadAuth(mDropboxAPI.getSession()); /* ######## DROP BOX CORE API */ AndroidAuthSession session = mApi.getSession(); // The next part must be inserted in the onResume() method of the // activity from which session.startAuthentication() was called, so // that Dropbox authentication completes properly. if (session.authenticationSuccessful()) { try { // Mandatory call to complete the auth session.finishAuthentication(); // Store it locally in our app for later use storeAuth(session); setLoggedIn(true); } catch (IllegalStateException e) { showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage()); Log.i(TAG, "Error authenticating", e); } } /* ######## DROP BOX CORE API */ }
Example #7
Source File: DropBoxHelper.java From android-auto-call-recorder with MIT License | 4 votes |
public DropBoxHelper(Context context) { mContext = context; AndroidAuthSession session = buildSession(); mApi = new DropboxAPI<>(session); }
Example #8
Source File: DropBoxHelper.java From android-auto-call-recorder with MIT License | 4 votes |
public DropboxAPI<AndroidAuthSession> getApi() { return mApi; }