Hi,
I'm trying to connect to BigQuery using the Google API Client for Java and using a service account. I've set up the service account in the API console and granted this user access to the appropriate dataset.
I'm creating a GoogleCredential and passing it as a HttpRequestInitializer to Bigquery:
GoogleCredential credential = new GoogleCredential.Builder().setTransport(transport)
.setJsonFactory(factory)
.setServiceAccountId("[[serviceAcountEmail]]")
.setServiceAccountScopes(BigqueryScopes.BIGQUERY)
.setServiceAccountPrivateKey(privateKey)
.build();
Bigquery bq = Bigquery.builder(transport, factory).setHttpRequestInitializer(initializer).build();
The value [[serviceAcountEmail]] is replaced by the actual service account email. The privateKey has been loaded using PrivateKeys.loadFromKeyStore().
But I get the following response when trying to do a query:
[ERROR] com.google.api.client.googleapis.json.GoogleJsonResponseException: 403
[ERROR] {
[ERROR] "code" : 403,
[ERROR] "errors" : [ {
[ERROR] "domain" : "usageLimits",
[ERROR] "message" : "Access Not Configured",
[ERROR] "reason" : "accessNotConfigured"
[ERROR] } ],
[ERROR] "message" : "Access Not Configured"
[ERROR] }
What steps do I have to take to get this working? A post in another forum (about another API) pointed me towards the API console to set up traffic filtering, but I could not find how to do this.
Thanks,
Alexander