Search code examples
javagoogle-bigquerygoogle-oauthgoogle-cloud-storagegoogle-cloud-datastore

Error 403 Forbidden (insufficient permission) with Google Cloud Storage JSON API Java example


I am trying this example from Google, showing "how you can use the Google APIs Client Library for Java to send requests to the Google Cloud Storage JSON API", which lists the content of one bucket. The only difference is that I am using Eclipse (with Maven) on Linux instead of Maven directly. I keep getting the following error message, generated by the line Bucket bucket = getBucket.execute();:

403 Forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Insufficient Permission", "reason" : "insufficientPermissions" } ], "message" : "Insufficient Permission" }

However, I have read/write access to the project, I am able to inspect the buckets through the developers console and I have been able to access BigQuery through the Java API (although I'm also running into some strange behaviour there, I can detail if necessary). My ultimate goal is to write a script that loads new Datastore backups into BigQuery every day.

Can anyone confirm that the example from Google is working for them?

EDIT: I should add that I have no trouble using the 'APIs exporer' here.


Solution

  • We finally managed to solve the problem, by doing two things: physically deleting the access token (letting it be recreated by the code) and 'cleaning' the project in Eclipse. Not sure which of the two was more important. The first step alone was not enough, but it did have an effect: now I was being asked to grant permission in the browser over and over again, something that wouldn't happen before.

    My only explanation is that the access token contained outdated information that led to the failure of the authentication, but I'm not sure whether that's possible. (If so, it sounds like a bug.)