Package com.google.api.client.auth.oauth2

Examples of com.google.api.client.auth.oauth2.MyTransport


     * Overriding is only supported for the purpose of calling the super implementation and changing
     * the return type, but nothing else.
     * </p>
     */
    public Builder setClientSecrets(String clientId, String clientSecret) {
      setClientAuthentication(new ClientParametersAuthentication(clientId, clientSecret));
      return this;
    }
View Full Code Here


     * </p>
     */
    public Builder setClientSecrets(GoogleClientSecrets clientSecrets) {
      Details details = clientSecrets.getDetails();
      setClientAuthentication(
          new ClientParametersAuthentication(details.getClientId(), details.getClientSecret()));
      return this;
    }
View Full Code Here

    public static void main(String[] args) {
      try {
        try {
          HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
          // authorization
          Credential credential = authorize();

          // set up global Calendar instance
          client = new com.google.api.services.calendar.Calendar.Builder(
              HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(
              APPLICATION_NAME).build();
View Full Code Here

  }

  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());
  }
View Full Code Here

  }

  public void testLoadCredentials_empty() throws Exception {
    File file = createTempFile();
    FileCredentialStore store = new FileCredentialStore(file, JSON_FACTORY);
    Credential actual = createEmptyCredential();
    boolean loaded = store.load(USER_ID, actual);
    assertFalse(loaded);
    assertNull(actual.getAccessToken());
    assertNull(actual.getRefreshToken());
    assertNull(actual.getExpirationTimeMilliseconds());
  }
View Full Code Here

    assertNull(actual.getRefreshToken());
    assertNull(actual.getExpirationTimeMilliseconds());
  }

  public void testStoreCredentials() throws Exception {
    Credential expected = createCredential();
    File file = createTempFile();
    file.delete();
    FileCredentialStore store = new FileCredentialStore(file, JSON_FACTORY);
    store = new FileCredentialStore(file, JSON_FACTORY);
    store.store(USER_ID, expected);

    store = new FileCredentialStore(file, JSON_FACTORY);
    Credential actual = createEmptyCredential();
    boolean loaded = store.load(USER_ID, actual);
    assertTrue(loaded);
    assertEquals(ACCESS_TOKEN, actual.getAccessToken());
    assertEquals(REFRESH_TOKEN, actual.getRefreshToken());
    assertEquals(EXPIRES_IN, actual.getExpirationTimeMilliseconds().longValue());
  }
View Full Code Here

    assertEquals(REFRESH_TOKEN, actual.getRefreshToken());
    assertEquals(EXPIRES_IN, actual.getExpirationTimeMilliseconds().longValue());
  }

  public void testNotLoadCredentials() throws Exception {
    Credential expected = createCredential();
    FileCredentialStore store = new FileCredentialStore(createTempFile(), JSON_FACTORY);
    store.store(USER_ID, expected);
    try {
      store.load(USER_ID, null);
      fail("expected " + NullPointerException.class);
View Full Code Here

    FileCredentialStore store = new FileCredentialStore(createTempFile(), JSON_FACTORY);
    store.delete(USER_ID, createCredential());
  }

  private Credential createCredential() {
    Credential access = new Credential.Builder(
        BearerToken.queryParameterAccessMethod()).setTransport(new AccessTokenTransport())
        .setJsonFactory(JSON_FACTORY)
        .setTokenServerUrl(TOKEN_SERVER_URL)
        .setClientAuthentication(new BasicAuthentication(CLIENT_ID, CLIENT_SECRET))
        .build()
View Full Code Here

        .setExpirationTimeMilliseconds(EXPIRES_IN);
    return access;
  }

  private Credential createEmptyCredential() {
    Credential access = new Credential.Builder(
        BearerToken.queryParameterAccessMethod()).setTransport(new AccessTokenTransport())
        .setJsonFactory(JSON_FACTORY)
        .setTokenServerUrl(TOKEN_SERVER_URL)
        .setClientAuthentication(new BasicAuthentication(CLIENT_ID, CLIENT_SECRET))
        .build();
View Full Code Here

  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());
  }
View Full Code Here

TOP

Related Classes of com.google.api.client.auth.oauth2.MyTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.