/java-docs-samples

Primary LanguageJavaApache License 2.0Apache-2.0

java-docs-samples

Kokoro Build Status Coverage Status

Open in Cloud Shell

While this library is still supported, we suggest trying the newer Cloud Client Library for Google Cloud Vision, especially for new projects. For more information, please see the notice on the API Client Library Page.

This is a repository that contains java code snippets on Cloud Platform Documentation.

Technology Samples:

Credentials Example

The documentation for Application Default Credentials.

BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();

The client library looks for credentials using the following rules:

  1. GOOGLE_APPLICATION_CREDENTIALS environment variable, pointing to a service account key JSON file path.
  2. Cloud SDK credentials gcloud auth application-default login
  3. App Engine standard environment credentials.
  4. Compute Engine credentials.

You can override this behavior using setCredentials in BigQueryOptions.newBuilder() by adding setCredentials(Credentials credentials) from ServiceOptions.builder and Credentials.