I'm trying to instantiate BigQueryTemplate without the environment variable GOOGLE_APPLICATION_CREDENTIALS.

Steps tried:

  1. Implemented CredentialsSupplier by instantiating Credentials and setting location to service account json file.
  2. Instantiated Bean BigQuery using BigQueryOptions::newBuilder() and setting credentials and project id.
  3. Instantiating Bean BigQueryTemplate using the BigQuery bean created in step 2.

spring-cloud-gcp-dependencies 3.4.0 version is used.

The application executing in VM (non-gcp env).

Another option I tried is adding below properties

  1. spring.cloud.gcp.bigquery.dataset-name=datasetname
  2. spring.cloud.gcp.bigquery.credentials.location=file:/path/to/json
  3. spring.cloud.gcp.bigquery.project-id=project-id

I'm getting below error

com.google.cloud.spring.bigquery.core.BigQueryTemplate,
applog.mthd=lambda$writeJsonStream$0,
applog.line=299, applog.msg=Error: 
The Application Default Credentials are not available. 
They are available if running in Google Compute Engine. 
Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials.

Please let me know if I have missed any thing. Thanks in advance.

0

There are 0 best solutions below