com.google.api.client.auth.oauth2.StoredCredential

Here are the examples of the java api class com.google.api.client.auth.oauth2.StoredCredential taken from open source projects.

1. AppEngineCredentialStoreTest#testMigrateTo()

View license
public void testMigrateTo() throws Exception {
    // create old store
    AppEngineCredentialStore store = new AppEngineCredentialStore();
    Credential expected = createCredential();
    store.store(USER_ID, expected);
    // migrate to new store
    AppEngineDataStoreFactory newFactory = new AppEngineDataStoreFactory();
    store.migrateTo(newFactory);
    // check new store
    DataStore<StoredCredential> newStore = newFactory.getDataStore(StoredCredential.DEFAULT_DATA_STORE_ID);
    assertEquals(ImmutableSet.of(USER_ID), newStore.keySet());
    StoredCredential actual = newStore.get(USER_ID);
    assertEquals(expected.getAccessToken(), actual.getAccessToken());
    assertEquals(expected.getRefreshToken(), actual.getRefreshToken());
    assertEquals(expected.getExpirationTimeMilliseconds(), actual.getExpirationTimeMilliseconds());
}

2. FileCredentialStoreTest#testMigrateTo()

View license
public void testMigrateTo() throws Exception {
    // create old store
    File file = createTempFile();
    FileCredentialStore store = new FileCredentialStore(file, JSON_FACTORY);
    Credential expected = createCredential();
    store.store(USER_ID, expected);
    // migrate to new store
    File dataDir = Files.createTempDir();
    dataDir.deleteOnExit();
    FileDataStoreFactory newFactory = new FileDataStoreFactory(dataDir);
    store.migrateTo(newFactory);
    // check new store
    DataStore<StoredCredential> newStore = newFactory.getDataStore(StoredCredential.DEFAULT_DATA_STORE_ID);
    assertEquals(ImmutableSet.of(USER_ID), newStore.keySet());
    StoredCredential actual = newStore.get(USER_ID);
    assertEquals(expected.getAccessToken(), actual.getAccessToken());
    assertEquals(expected.getRefreshToken(), actual.getRefreshToken());
    assertEquals(expected.getExpirationTimeMilliseconds(), actual.getExpirationTimeMilliseconds());
}