I'm trying to use google cloud storage java library in scala to list items in a bucket
val credential = new GoogleCredential.Builder()
.setTransport(GoogleNetHttpTransport.newTrustedTransport())
.setJsonFactory(JacksonFactory.getDefaultInstance())
.setServiceAccountId("[email protected]")
.setServiceAccountScopes(Collections.singleton(StorageScopes.DEVSTORAGE_READ_ONLY))
.setServiceAccountPrivateKeyFromP12File(new File("file.p12"))
.build()
val storage = new Storage.Builder(
GoogleNetHttpTransport.newTrustedTransport(),
JacksonFactory.getDefaultInstance(),
credential)
.setHttpRequestInitializer(credential)
.setApplicationName("app")
.build()
storage.objects.list("bucket").execute
however I got
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Forbidden",
"reason" : "forbidden"
} ],
"message" : "Forbidden"
}
my email account have the access to the bucket, I can access it using gsutil by creating a project in my account as well. I've created [email protected] in a project in my account as well, any idea that how can I set the permission?
Just been coming up against the same issue, and think we've found the solution. To fix it, the owner of the Google Play Developer Console that we were trying to access had to add our service account email address to the Google Play Console permissions list, and give the service account Financial Reports privileges.
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