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


Java DataStore.set方法代码示例

本文整理汇总了Java中com.google.api.client.util.store.DataStore.set方法的典型用法代码示例。如果您正苦于以下问题:Java DataStore.set方法的具体用法?Java DataStore.set怎么用?Java DataStore.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.util.store.DataStore的用法示例。


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

示例1: storeOAuth2TokenData

import com.google.api.client.util.store.DataStore; //导入方法依赖的package包/类
/**
 * Stores the given OAuth 2 token response within a file data store.
 * The stored token response can then retrieved using the getOAuth2TokenDataFromStore method.
 *
 * @param storageId a string object that is used to store the token response
 * @param tokenResponse the token response containing the OAuth 2 token information.
 * @return If the token response was stored or not.
 */
public Boolean storeOAuth2TokenData(String storageId, TokenResponse tokenResponse) {
    Boolean wasStored = false;
    try {
        File oauth2StorageFolder = new File(this.context.getFilesDir(),"oauth2StorageFolder");
        oauth2StorageFolder.mkdirs();
        FileDataStoreFactory fileDataStoreFactory = new FileDataStoreFactory(oauth2StorageFolder);
        DataStore<StoredCredential> storedCredentialDataStore = fileDataStoreFactory.getDataStore(storageId);
        Credential oauth2Credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
                tokenResponse);
        StoredCredential storedOAuth2Credential = new StoredCredential(oauth2Credential);
        storedCredentialDataStore.set(storageId,storedOAuth2Credential);
        wasStored = true;
    } catch ( Exception exception ) {
        logInfo("Exception storing OAuth2TokenData :" + exception.getLocalizedMessage());
    }
    return wasStored;
}
 
开发者ID:apigee,项目名称:apigee-android-sdk,代码行数:26,代码来源:ApigeeDataClient.java

示例2: addCredentialToDataStore

import com.google.api.client.util.store.DataStore; //导入方法依赖的package包/类
private void addCredentialToDataStore(File dataStoreDir, StoredCredential credential) throws IOException {
	FileDataStoreFactory dataStoreFactory = new FileDataStoreFactory(dataStoreDir);
	DataStore<StoredCredential> dataStore = dataStoreFactory.getDataStore(DEFAULT_DATA_STORE_ID);
	dataStore.set("user", credential);		
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:6,代码来源:GDriveConnectionManagerTest.java


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