I want to use this library
com.google.cloud.bigquery.BigQuery
as in the example:
https://cloud.google.com/bigquery/create-simple-app-api
However I want to authenticate the BigQuery client with service account.
How can I do this?
I see only a default credentials way.
BigQuery bigquery =
new BigQueryOptions.DefaultBigqueryFactory().create(BigQueryOptions.defaultInstance());
Try using setCredentials and ServiceAccountCredentials.fromStream while building the service.
BigQuery bigquery = BigQueryOptions.newBuilder()
.setCredentials(
ServiceAccountCredentials.fromStream(
new FileInputStream("your_json_service_keyfile.json"))
)
.build().getService()
This ought to be better documented in Google's API doc.
Hope it helps, it's my first answer on stackoverflow :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With