Examples of GoogleClientSecrets


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

      .setTransport(HTTP_TRANSPORT).setJsonFactory(JSON_FACTORY).build();

  /** Authorizes the installed application to access user's protected data. */
  private static Credential authorize() throws Exception {
    // load client secrets
    GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
        JSON_FACTORY,
        Main.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=prediction "
              + "into prediction-cmdline-sample/src/main/resources/client_secrets.json");
      System.exit(1);
View Full Code Here

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

     */
    public static Credential authorize(List<String> scopes, String credentialDatastore) throws IOException {

        // Load client secrets.
        Reader clientSecretReader = new InputStreamReader(Auth.class.getResourceAsStream("/client_secrets.json"));
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, clientSecretReader);

        // Checks that the defaults have been replaced (Default = "Enter X here").
        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=youtube"
                            + "into src/main/resources/client_secrets.json");
            System.exit(1);
        }
View Full Code Here

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

            }
        };
    }

    protected void handleTokens(Map<String, String> params) {
        final GoogleClientSecrets secrets = new GoogleClientSecrets().setInstalled(
                new GoogleClientSecrets.Details().
                        setClientId(params.get(constants.getApplicationClientId())).
                        setClientSecret(params.get(constants.getApplicationClientSecret()))
        );

        try {
            final GoogleTokenResponse tokenResponse = new GoogleAuthorizationCodeTokenRequest(
                    this.httpTransport,
                    this.jsonFactory,
                    secrets.getDetails().getClientId(),
                    secrets.getDetails().getClientSecret(),
                    params.get(constants.getApplicationOauthCode()),
                    constants.getRedirectUri()
            ).execute();

            params.put(constants.getApplicationRefreshToken(), tokenResponse.getRefreshToken());
View Full Code Here

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

    protected void handleBuildFinished(SRunningBuild build, SBuildFeatureDescriptor feature) {
        final Map<String, String> parameters = feature.getParameters();
        final BuildStatistics fullBuildStatistics = build.getFullStatistics();

        // prepare the endpoint authentication
        final GoogleClientSecrets secrets = new GoogleClientSecrets().setInstalled(
                new GoogleClientSecrets.Details().
                        setClientId(parameters.get(constants.getApplicationClientId())).
                        setClientSecret(parameters.get(constants.getApplicationClientSecret()))
        );
View Full Code Here

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

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

    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

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

      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

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

  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

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

      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

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

     */
    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
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.