当前位置: 首页>>代码示例>>Java>>正文


Java AccessTokenPair类代码示例

本文整理汇总了Java中com.dropbox.client2.session.AccessTokenPair的典型用法代码示例。如果您正苦于以下问题:Java AccessTokenPair类的具体用法?Java AccessTokenPair怎么用?Java AccessTokenPair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AccessTokenPair类属于com.dropbox.client2.session包,在下文中一共展示了AccessTokenPair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isLinked

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
public boolean isLinked(Activity activity) {
		try {

		AppKeyPair appKeys = new AppKeyPair(StaticConfig.dropboxAppKey, StaticConfig.dropboxAppSecret);
		AndroidAuthSession session = new AndroidAuthSession(appKeys, AccessType.DROPBOX);
		api = new DropboxAPI<AndroidAuthSession>(session);		
//		
		KeyValueBean loginPwd = getLoginPwd(activity);
		AccessTokenPair atp = new AccessTokenPair(loginPwd.getKey(),loginPwd.getValue());
		api.getSession().setAccessTokenPair(atp);
//		return api.getSession().isLinked();
		api.metadata("/", 1, null, false, null);
		return true;
		}
		catch (DropboxException e){
			return false;
		}
		

	}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:21,代码来源:FileProvider4.java

示例2: prepareDbApi

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
private void prepareDbApi() {
	String keys[] = getKeys();
	if (keys == null) {
		Log.e(TAG, "No stored tokens, please have the user login.");
		
	} else {
	
		String key = keys[0];
		String secret = keys[1];
		if (key.length() < 1 || secret.length() < 1) {
			Log.e(TAG, "Stored tokens are empty! Have the user login again.");
		}			
		AccessTokenPair access = new AccessTokenPair(key, secret);
		dbApi.getSession().setAccessTokenPair(access);
	}
}
 
开发者ID:roadlabs,项目名称:alternate-java-bridge-library,代码行数:17,代码来源:DropBoxClient.java

示例3: onResume

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
@Override
public void onResume() {
	if (dbApi != null) {
		if (dbApi.getSession().authenticationSuccessful()) {
			try {
            // 	MANDATORY call to complete auth.
            // 	Sets the access token on the session
				dbApi.getSession().finishAuthentication();
				
				AccessTokenPair tokens = dbApi.getSession().getAccessTokenPair();
            
				// Store the tokens in this app's prefs file to grab later.					
            
				storeKeys(tokens.key, tokens.secret);
				loggedIn = true;
				EventDispatcher.dispatchEvent(this, "LoginResponse", true);
			} catch (IllegalStateException e) {
				Log.i("DropBoxClient", "Error authenticating", e);
				EventDispatcher.dispatchEvent(this, "LoginResponse", false);
			}
		} 
	}
}
 
开发者ID:roadlabs,项目名称:alternate-java-bridge-library,代码行数:24,代码来源:DropBoxClient.java

示例4: loadAuth

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
protected void loadAuth(AndroidAuthSession session) {
    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences(mContext);
    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));
    }
}
 
开发者ID:sysnetlab,项目名称:SensorDataCollector,代码行数:20,代码来源:DropboxHelper.java

示例5: loadAuth

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
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)
    {
        Log.d(TAG,"No key found");
        return;
    }

    if (key.equals("oauth2:")) {
        // If the key is set to "oauth2:", then we can assume the token is for OAuth 2.
        Log.d(TAG,"OAuth 2 token found");
        session.setOAuth2AccessToken(secret);
    } else {
        // Still support using old OAuth 1 tokens.
        Log.d(TAG,"OAuth 1 keypair found");
        session.setAccessTokenPair(new AccessTokenPair(key, secret));
    }
}
 
开发者ID:bright-tools,项目名称:androidphotobackup,代码行数:21,代码来源:DropBoxWrapper.java

示例6: finishAuthentication

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
public void finishAuthentication() throws IllegalStateException {
	if (getSession().isLinked()) {
		return;
	}
	if (getSession().authenticationSuccessful()) {
		getSession().finishAuthentication();

		AccessTokenPair tokens = getSession().getAccessTokenPair();

		// Provide your own storeKeys to persist the access token pair
		// A typical way to store tokens is using SharedPreferences
		storeKeys(tokens.key, tokens.secret);
	} else {
		throw new IllegalStateException(authentificationError);
	}
}
 
开发者ID:ironjan,项目名称:photodrop,代码行数:17,代码来源:SessionKeeper.java

示例7: doList

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
private static void doList(String[] args)
    throws DropboxException
{
    if (args.length != 1) {
        throw die("ERROR: \"list\" takes no arguments.");
    }

    // Load state.
    State state = State.load(STATE_FILE);

    if (state.links.isEmpty()) {
        System.out.println("No links.");
    }
    else {
        System.out.println("[uid: access token]");
        for (Map.Entry<String,AccessTokenPair> link : state.links.entrySet()) {
            AccessTokenPair at = link.getValue();
            System.out.println(link.getKey() + ": " + at.key + " " + at.secret);
        }
    }
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:22,代码来源:CopyBetweenAccounts.java

示例8: init

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
@Override
public void init(Configuration config) throws RepositoryException {
    String uid = config.getInitParameter("UID");
    if (StringUtils.isEmpty(uid)) {
        throw new RepositoryException("No UID param specified");
    }
    String rootPath = config.getInitParameter("RootPath");
    if (StringUtils.isEmpty(rootPath)) {
        throw new RepositoryException("No RootPath param specified");
    }        

    DropboxContext dropboxContext = getDropboxContext();

    AppKeyPair appKeyPair = dropboxContext.getAppKeyPair();
    if (appKeyPair == null) {
        throw new RepositoryException("No AppKeyPair found in DropboxContext");
    }
    AccessTokenPair accessTokenPair = dropboxContext.getAccessTokenPair(uid);
    if (accessTokenPair == null) {
        throw new RepositoryException("No AccessTokenPair found for uid '" + uid + "' in DropboxContext");
    }

    dropboxClient = new DropboxClient(uid, appKeyPair, accessTokenPair, rootPath);
    repositoryUrl = "dropbox://" + uid + (rootPath.startsWith("/")? "" : "/") + rootPath;
}
 
开发者ID:avasquez614,项目名称:cloud-raid,代码行数:26,代码来源:DropboxFragmentRepository.java

示例9: DropboxAPISession

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
private DropboxAPISession(Context context) {

        mPreference = context.getSharedPreferences(PREF_NAME,
                Context.MODE_PRIVATE);
        String token = mPreference.getString(KEY_ACCESS_TOKEN, null);
        String secret = mPreference.getString(KEY_ACCESS_TOKEN_SECRET, null);
        if (token != null && secret != null) {
            AppKeyPair appKeys = new AppKeyPair(Settings.API_KEY,
                    Settings.API_SECRET);
            AndroidAuthSession session = new AndroidAuthSession(appKeys,
                    ACCESS_TYPE);
            mDBApi = new DropboxAPI<AndroidAuthSession>(session);
            mTokens = new AccessTokenPair(token, secret);
            mDBApi.getSession().setAccessTokenPair(mTokens);
        }

    }
 
开发者ID:sys1yagi,项目名称:DropboxPrintService,代码行数:18,代码来源:DropboxAPISession.java

示例10: initSession

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
private void initSession(DropboxServer server) {
    AppKeyPair appKeyPair = new AppKeyPair(server.APP_KEY, server.APP_SECRET);
    WebAuthSession webAuthSession = new WebAuthSession(appKeyPair, DropboxSdk.ACCESS_TYPE);
    dropboxAPI = new DropboxAPI<WebAuthSession>(webAuthSession);
    AccessTokenPair accessTokenPair = new AccessTokenPair(server.AUTH_KEY, server.AUTH_SECRET);
    dropboxAPI.getSession().setAccessTokenPair(accessTokenPair);
}
 
开发者ID:MarkXLII,项目名称:subtitle-studio,代码行数:8,代码来源:DropboxSdk.java

示例11: getDropboxKeys

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
public static AccessTokenPair getDropboxKeys(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    String authKey = sharedPreferences.getString(DROPBOX_AUTH_KEY, null);
    String authSecret = sharedPreferences.getString(DROPBOX_AUTH_SECRET, null);
    if (authKey != null && authSecret != null) {
        return new AccessTokenPair(authKey, authSecret);
    }
    return null;
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:10,代码来源:MyPreferences.java

示例12: completeAuth

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
public void completeAuth() {
    try {
        if (startedAuth && dropboxApi.getSession().authenticationSuccessful()) {
            try {
                dropboxApi.getSession().finishAuthentication();
                AccessTokenPair tokens = dropboxApi.getSession().getAccessTokenPair();
                MyPreferences.storeDropboxKeys(context, tokens.key, tokens.secret);
            } catch (IllegalStateException e) {
                Log.i("Flowzr", "Error authenticating Dropbox", e);
            }
        }
    } finally {
        startedAuth = false;
    }
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:16,代码来源:Dropbox.java

示例13: authSession

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
public boolean authSession() {
    AccessTokenPair access = MyPreferences.getDropboxKeys(context);
    if (access != null) {
        dropboxApi.getSession().setAccessTokenPair(access);
        return dropboxApi.getSession().isLinked();
    }
    return false;
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:9,代码来源:Dropbox.java

示例14: loadAuth

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
/**
 * 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 = activity.getSharedPreferences("ACCOUNT_PREFS_NAME", 0);
  String key = prefs.getString(DROPBOX_PREFKEY_NAME, null);
  String secret = prefs.getString(DROPBOX_PREFKEY_SECRET, 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));
  }
}
 
开发者ID:carlosmuvi,项目名称:clean-ebook-library,代码行数:20,代码来源:DropboxDatasource.java

示例15: doLink

import com.dropbox.client2.session.AccessTokenPair; //导入依赖的package包/类
private static void doLink(String[] args)
    throws DropboxException
{
    if (args.length != 1) {
        throw die("ERROR: \"link\" takes no arguments.");
    }

    // Load state.
    State state = State.load(STATE_FILE);

    WebAuthSession was = new WebAuthSession(state.appKey, Session.AccessType.APP_FOLDER);

    // Make the user log in and authorize us.
    WebAuthSession.WebAuthInfo info = was.getAuthInfo();
    System.out.println("1. Go to: " + info.url);
    System.out.println("2. Allow access to this app.");
    System.out.println("3. Press ENTER.");

    try {
        while (System.in.read() != '\n') {}
    }
    catch (IOException ex) {
        throw die("I/O error: " + ex.getMessage());
    }

    // This will fail if the user didn't visit the above URL and hit 'Allow'.
    String uid = was.retrieveWebAccessToken(info.requestTokenPair);
    AccessTokenPair accessToken = was.getAccessTokenPair();
    System.out.println("Link successful.");

    state.links.put(uid, accessToken);
    state.save(STATE_FILE);
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:34,代码来源:CopyBetweenAccounts.java


注:本文中的com.dropbox.client2.session.AccessTokenPair类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。