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

Examples of com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets


  public static void main(String[] args) throws Exception {
    // Get the client ID and secret from the ads.properties file.
    // If you do not have a client ID or secret, please create one in the
    // API console: https://code.google.com/apis/console#access and set it
    // in the ads.properties file.
    GoogleClientSecrets clientSecrets = null;
    try {
      clientSecrets = new GoogleClientSecretsBuilder()
          .forApi(Api.ADWORDS)
          .fromFile()
          .build();
View Full Code Here


    if (Strings.isNullOrEmpty(clientSecret)) {
      System.err.println("Please input your client secret.");
      System.exit(1);
    }

    GoogleClientSecrets clientSecrets = null;
    try {
      clientSecrets = new GoogleClientSecretsBuilder()
          .forApi(Api.ADWORDS)
          .withClientSecrets(clientId, clientSecret)
          .build();
View Full Code Here

      t.printStackTrace();
    }
  }

  private static Credential authorize() throws Exception {
    GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(Test.class.getResourceAsStream("/client_secrets.json")));
    if (clientSecrets.getDetails().getClientId().startsWith("Enter") || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) {
      System.out.println("Enter Client ID and Secret from https://code.google.com/apis/console/?api=analytics into analytics-cmdline-sample/src/main/resources/client_secrets.json");
      System.exit(1);
    }

    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
View Full Code Here

  private static String REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob";

  public static void main(String[] args) throws Exception {
    HttpTransport httpTransport = new NetHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();
    GoogleClientSecrets clientSecrets =
        GoogleClientSecrets.load(
            jsonFactory,
            new InputStreamReader(AccessTokenGeneratorApplication.class
                .getResourceAsStream(CLIENTSECRETS_LOCATION)));
View Full Code Here

      JsonFactory jsonFactory = new JacksonFactory();

      URL url = Resources.getResource(GDrive.class, CLIENTSECRETS_LOCATION);
      CharSource charSource = Resources.asCharSource(url, Charsets.UTF_8);
      Reader reader = charSource.openStream();
      GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(jsonFactory, reader);

      GoogleCredential credential = new GoogleCredential.Builder()
          .setTransport(httpTransport)
          .setJsonFactory(jsonFactory)
          .setClientSecrets(clientSecrets)
View Full Code Here

     */
    private static Credential authorizeWithInstalledApplication(File secretFile, File authStore) throws IOException {
        log.info("Authorizing using installed application");

        // load client secrets
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
                JSON_FACTORY,
                new FileReader(secretFile));
        // Ensure file has been filled out.
        checkClientSecretsFile(clientSecrets);

View Full Code Here

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

    GoogleClientSecrets googleClientSecrets = new GoogleClientSecretsBuilder()
        .forApi(GoogleClientSecretsBuilder.Api.DFP)
        .from(config)
        .build();

    assertEquals(googleClientSecrets.getInstalled().getClientId(), "clientId");
    assertEquals(googleClientSecrets.getInstalled().getClientSecret(), "clientSecret");
  }
View Full Code Here

    config.setProperty("api.dfp.clientId", "clientIdDfp");
    config.setProperty("api.dfp.clientSecret", "clientSecretDfp");
    config.setProperty("api.adwords.clientId", "clientIdAdWords");
    config.setProperty("api.adwords.clientSecret", "clientSecretAdWords");

    GoogleClientSecrets googleClientSecrets = new GoogleClientSecretsBuilder()
        .forApi(GoogleClientSecretsBuilder.Api.DFP)
        .from(config)
        .build();

    assertEquals(googleClientSecrets.getInstalled().getClientId(), "clientIdDfp");
    assertEquals(googleClientSecrets.getInstalled().getClientSecret(), "clientSecretDfp");
  }
View Full Code Here

  @Test(expected = ValidationException.class)
  public void testGoogleSecretsReadPropertiesFromConfiguration_missingClientId() throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("api.dfp.clientSecret", "clientSecret");

    GoogleClientSecrets googleClientSecrets = new GoogleClientSecretsBuilder()
        .forApi(GoogleClientSecretsBuilder.Api.DFP)
        .from(config)
        .build();
  }
View Full Code Here

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

    GoogleClientSecrets googleClientSecrets = new GoogleClientSecretsBuilder()
        .forApi(GoogleClientSecretsBuilder.Api.DFP)
        .from(config)
        .build();
  }
View Full Code Here

TOP

Related Classes of com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets

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.