Package com.google.api.ads.common.lib.auth.OfflineCredentials

Examples of com.google.api.ads.common.lib.auth.OfflineCredentials.ForApiBuilder


    config.setProperty("api.dfp.clientSecret", "clientSecret");
    config.setProperty("api.dfp.refreshToken", "refreshToken");

    when(configurationHelper.fromFile("path")).thenReturn(config);

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    OfflineCredentials offlineCredentials = builder.fromFile("path").build();

    assertEquals(offlineCredentials.getClientId(), "clientId");
    assertEquals(offlineCredentials.getClientSecret(), "clientSecret");
    assertEquals(offlineCredentials.getRefreshToken(), "refreshToken");
  }
View Full Code Here


    config.setProperty("api.dfp.clientSecret", "clientSecret");
    config.setProperty("api.dfp.refreshToken", "refreshToken");

    when(configurationHelper.fromFile("path")).thenReturn(config);

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    OfflineCredentials offlineCredentials =
        builder.fromFile("path").withRefreshToken("overrideRefreshToken").build();

    assertEquals(offlineCredentials.getClientId(), "clientId");
    assertEquals(offlineCredentials.getClientSecret(), "clientSecret");
    assertEquals(offlineCredentials.getRefreshToken(), "overrideRefreshToken");
  }
View Full Code Here

    config.setProperty("api.dfp.clientId", "clientId");
    config.setProperty("api.dfp.clientSecret", "clientSecret");

    when(configurationHelper.fromFile("/home/user/path")).thenReturn(config);

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    try {
      OfflineCredentials offlineCredentials = builder.fromFile("/home/user/path").build();
      fail("Validation exception should have been thrown");
    } catch (ValidationException e) {
      assertEquals("A refresh token must be set as api.dfp.refreshToken in /home/user/path."
          + "\nIt is required for offline credentials. If you need to create one, "
          + "see the GetRefreshToken example.", e.getMessage());
View Full Code Here

  public void testReadPropertiesFromFile_refreshTokenNoFilePath() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.dfp.clientId", "clientId");
    config.setProperty("api.dfp.clientSecret", "clientSecret");

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    try {
      OfflineCredentials offlineCredentials = builder.from(config).build();
      fail("Validation exception should have been thrown");
    } catch (ValidationException e) {
      assertEquals("A refresh token must be set."
          + "\nIt is required for offline credentials. If you need to create one, "
          + "see the GetRefreshToken example.", e.getMessage());
View Full Code Here

    config.setProperty("api.dfp.clientSecret", "clientSecret");
    config.setProperty("api.dfp.refreshToken", "refreshToken");

    when(configurationHelper.fromFile("/home/user/path")).thenReturn(config);

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    try {
      OfflineCredentials offlineCredentials = builder.fromFile("/home/user/path").build();
      fail("Validation exception should have been thrown");
    } catch (ValidationException e) {
      assertEquals("Client ID must be set as api.dfp.clientId in /home/user/path."
          + "\nIf you do not have a client ID or secret, please create one in the API "
          + "console: https://code.google.com/apis/console#access", e.getMessage());
View Full Code Here

  public void testReadPropertiesFromFile_clientIdNoFilePath() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.dfp.clientSecret", "clientSecret");
    config.setProperty("api.dfp.refreshToken", "refreshToken");

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    try {
      OfflineCredentials offlineCredentials = builder.from(config).build();
      fail("Validation exception should have been thrown");
    } catch (ValidationException e) {
      assertEquals("Client ID must be set."
          + "\nIf you do not have a client ID or secret, please create one in the API "
          + "console: https://code.google.com/apis/console#access", e.getMessage());
View Full Code Here

    config.setProperty("api.dfp.clientId", "clientId");
    config.setProperty("api.dfp.refreshToken", "refreshToken");

    when(configurationHelper.fromFile("/home/user/path")).thenReturn(config);

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    try {
      OfflineCredentials offlineCredentials = builder.fromFile("/home/user/path").build();
      fail("Validation exception should have been thrown");
    } catch (ValidationException e) {
      assertEquals("Client secret must be set as api.dfp.clientSecret in /home/user/path."
          + "\nIf you do not have a client ID or secret, please create one in the API "
          + "console: https://code.google.com/apis/console#access", e.getMessage());
View Full Code Here

  public void testReadPropertiesFromFile_clientSecretNoFilePath() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.dfp.clientId", "clientId");
    config.setProperty("api.dfp.refreshToken", "refreshToken");

    ForApiBuilder builder = new OfflineCredentials.ForApiBuilder(
        configurationHelper, OfflineCredentials.Api.DFP, oAuth2Helper);

    try {
      OfflineCredentials offlineCredentials = builder.from(config).build();
      fail("Validation exception should have been thrown");
    } catch (ValidationException e) {
      assertEquals("Client secret must be set."
          + "\nIf you do not have a client ID or secret, please create one in the API "
          + "console: https://code.google.com/apis/console#access", e.getMessage());
View Full Code Here

TOP

Related Classes of com.google.api.ads.common.lib.auth.OfflineCredentials.ForApiBuilder

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.