Reputation: 93
String projName = settings.getProject(); String bucketName = settings.getBucket();
System.out.println("Creating bucket, projName: "+projName+", bucketName: "+bucketName) ;
try {
@SuppressWarnings("unused")
Bucket createdBucket = storage.buckets().insert(projName,
new Bucket().setName(bucketName).setLocation("US")
).execute();
} catch (GoogleJsonResponseException e) {
GoogleJsonError error = e.getDetails();
if (error.getCode() == HTTP_CONFLICT
&& error.getMessage().contains("You already own this bucket.")) {
System.out.println("already exists");
} else {
System.out.println("Exception in tryCreateBucket: "+e);
throw e;
}
}
Output:
Creating bucket, projName: round-center-551, bucketName: 1904mybucketfoo
Exception in tryCreateBucket:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{ "code" : 403, "errors" : [ { "domain" : "global" "location" : "Authorization", "locationType" : "header", "message" : "The account for the specified project has been disabled.", "reason" : "accountDisabled" } ], "message" : "The account for the specified project has been disabled." } The account for the specified project has been disabled.
I have verified that Google Cloud Storage and Google Cloud Datastore API services are on. Any idea what should be done to enable the account?
Upvotes: 0
Views: 2950
Reputation: 11
This problem drove me crazy. If billing is enabled and the bucket exists yet you still recieve this error it's because you haven't logged in with Application Credentials (ADC), login like so and problem will vanish:
gcloud auth application-default login
Note that this creates a different credential file than a "normal" gcloud login, so just because you can use gcloud doesn't mean you have the ADC credentials!
Upvotes: 1
Reputation: 1489
Try setting the default account
gcloud auth application-default login
Upvotes: 1
Reputation: 10579
This error could mean a few things, but quite possibly just means that you haven't enabled billing for the project.
Google Cloud Storage requires that billing is enabled in order to create buckets and objects, however the error here isn't very descriptive.
You can enable billing on the Settings page for your project in the Cloud Console (https://console.developers.google.com/project/apps~PROJECT_NAME/settings)
Upvotes: 5