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

Examples of com.google.api.client.auth.oauth2.Credential.refreshToken()


    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();

    Credential defaultCredential = testProvider.getDefaultCredential(transport, JSON_FACTORY);
    assertNotNull(defaultCredential);

    assertTrue(defaultCredential.refreshToken());
    assertEquals(ACCESS_TOKEN, defaultCredential.getAccessToken());
  }

  public void testDefaultCredentialComputeErrorNotFound() throws IOException {
    MockMetadataServerTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);
View Full Code Here


    Credential defaultCredential = testProvider.getDefaultCredential(transport, JSON_FACTORY);
    assertNotNull(defaultCredential);

    try {
      defaultCredential.refreshToken();
      fail("Expected error refreshing token.");
    } catch (IOException expected) {
      String message = expected.getMessage();
      assertTrue(message.contains(Integer.toString(HttpStatusCodes.STATUS_CODE_NOT_FOUND)));
      assertTrue(message.contains("scope"));
View Full Code Here

    Credential defaultCredential = testProvider.getDefaultCredential(transport, JSON_FACTORY);
    assertNotNull(defaultCredential);

    try {
      defaultCredential.refreshToken();
      fail("Expected error refreshing token.");
    } catch (IOException expected) {
      String message = expected.getMessage();
      assertTrue(message.contains(Integer.toString(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)));
      assertTrue(message.contains("Unexpected"));
View Full Code Here

      Credential credential = testProvider.getDefaultCredential(transport, JSON_FACTORY);

      assertNotNull(credential);
      assertEquals(refreshTokenEnv, credential.getRefreshToken());
      assertTrue(credential.refreshToken());
      assertEquals(accessTokenEnv, credential.getAccessToken());
    } finally {
      if (wellKnownFile.exists()) {
        wellKnownFile.delete();
      }
View Full Code Here

      Credential credential = testProvider.getDefaultCredential(transport, JSON_FACTORY);

      assertNotNull(credential);
      assertEquals(refreshToken, credential.getRefreshToken());

      assertTrue(credential.refreshToken());
      assertEquals(ACCESS_TOKEN, credential.getAccessToken());
    } finally {
      if (userFile.exists()) {
        userFile.delete();
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.