Account for bucket "XXX" is disabled

By running the following code on my local machine to create a new repository in Google repository , I received a StorageException error : account for bucket "my -new-bucket-abc" is disabled .

String SERVICE_ACCOUNT_JSON_PATH = "C:\\gcpconfig\\My First Project-6f9cff47c4f0.json";

Storage storage =
    StorageOptions.newBuilder()
        .setCredentials(
            ServiceAccountCredentials.fromStream(
                new FileInputStream(SERVICE_ACCOUNT_JSON_PATH)))
        .build()
        .getService();

String bucketName = "my-new-bucket-abc";

// Creates the new bucket
Bucket bucket = storage.create(BucketInfo.of(bucketName));

System.out.printf("Bucket %s created.%n", bucket.getName());

However, I could download files from the Google store by running the following code:

String SERVICE_ACCOUNT_JSON_PATH = "C:\\gcpconfig\\My First Project-6f9cff47c4f0.json";

Storage storage =
    StorageOptions.newBuilder()
        .setCredentials(
            ServiceAccountCredentials.fromStream(
                new FileInputStream(SERVICE_ACCOUNT_JSON_PATH)))
        .build()
        .getService();

BlobId blobId = BlobId.of("nmjcloud_jar_test","addons/simple-bean-1.0.jar");
Blob blob = storage.get(blobId);

Path path = Paths.get("D:\\lib\\simple-bean-1.0.jar");
blob.downloadTo(path);

System.out.printf("Download successfully%n");

The full error message is as follows:

Exception in thread "main" com.google.cloud.storage.StorageException: The account for bucket "my-new-bucket-abc" has been disabled.
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:191)
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.create(HttpStorageRpc.java:221)
    at com.google.cloud.storage.StorageImpl$2.call(StorageImpl.java:112)
    at com.google.cloud.storage.StorageImpl$2.call(StorageImpl.java:109)
    at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:89)
    at com.google.cloud.RetryHelper.run(RetryHelper.java:74)
    at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:51)
    at com.google.cloud.storage.StorageImpl.create(StorageImpl.java:108)
    at com.example.storage.QuickstartSample.main(QuickstartSample.java:58)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "location" : "Authorization",
    "locationType" : "header",
    "message" : "The account for bucket \"my-new-bucket-abc\" has been disabled.",
    "reason" : "accountDisabled"
  } ],
  "message" : "The account for bucket \"my-new-bucket-abc\" has been disabled."
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.create(HttpStorageRpc.java:219)
    ... 7 more

Does this mean that the account I used is not allowed to create buckets?

When running on a GCP virtual machine with a service account key, I received the following error:

Caused by: com.google.cloud.storage.StorageException: Insufficient Permission
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate (HttpStorageRpc.java:191)
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.create (HttpStorageRpc.java:221)
    at com.google.cloud.storage.StorageImpl$2.call (StorageImpl.java:112)
    at com.google.cloud.storage.StorageImpl$2.call (StorageImpl.java:109)
    at com.google.api.gax.retrying.DirectRetryingExecutor.submit (DirectRetryingExecutor.java:89)
    at com.google.cloud.RetryHelper.run (RetryHelper.java:74)
    at com.google.cloud.RetryHelper.runWithRetries (RetryHelper.java:51)
    at com.google.cloud.storage.StorageImpl.create (StorageImpl.java:108)
    at com.example.storage.QuickstartSample.createBucket (QuickstartSample.java:33)
    at com.example.storage.QuickstartSample.main (QuickstartSample.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
    at java.lang.Thread.run (Thread.java:748)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "Insufficient Permission",
    "reason" : "insufficientPermissions"
  } ],
  "message" : "Insufficient Permission"
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from (GoogleJsonResponseException.java:146)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError (AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError (AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse (AbstractGoogleClientRequest.java:321)
    at com.google.api.client.http.HttpRequest.execute (HttpRequest.java:1065)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed (AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed (AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute (AbstractGoogleClientRequest.java:469)
    at com.google.cloud.storage.spi.v1.HttpStorageRpc.create (HttpStorageRpc.java:219)
    at com.google.cloud.storage.StorageImpl$2.call (StorageImpl.java:112)
    at com.google.cloud.storage.StorageImpl$2.call (StorageImpl.java:109)
    at com.google.api.gax.retrying.DirectRetryingExecutor.submit (DirectRetryingExecutor.java:89)
    at com.google.cloud.RetryHelper.run (RetryHelper.java:74)
    at com.google.cloud.RetryHelper.runWithRetries (RetryHelper.java:51)
    at com.google.cloud.storage.StorageImpl.create (StorageImpl.java:108)
    at com.example.storage.QuickstartSample.createBucket (QuickstartSample.java:33)
    at com.example.storage.QuickstartSample.main (QuickstartSample.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
    at java.lang.Thread.run (Thread.java:748)

I tried the GCP VM again and now it works.

Some settings of my Google cloud platform:

1. : enter image description here

2. :

{
  "type": "service_account",
  "project_id": "ornate-shine-192301",
  "private_key_id": "6f9cff47c4f0f8b1263bbf515f7e3318dcc88487",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHvLTQn5i0Aheb\nW9iUkaRpZiGACUrh694JAzckVPEdhDoLaV4ZBapnmYrJBqQIs8RFXRWajtOrjzbY\nKJXWhOdtIim72fB0KVENjTRmq2m+wWf+ks19/eWakzYlXvsry61GT44UfccCOYbU\nioyevhQtJ0mdpa7QtAtjWyFmNXHodLjHHiwhArRYRP4Mel0MkHKi64EZ5aDLEGer\nkjntqnDcni0giCQNcvJw8c9XBB64dDcldSc7ZZ8QGXgBwzqYCt1F7pjK8rg6CFBi\n8ZKmUaRpguG4pB229fuwTWwE++/WEUtmgvGV4iQ6u6Zzeiw8TPKzgYzrF7XmBu38\nzHa+5wkJAgMBAAECggEAOwz7yhf9De72arx/LgFXAcArlE5rAJr6pGB6e3fPZyIS\nBRCsPKqTpBhdUyxu75GyK62m9vBV/QkUtlhdYDQft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ssGtg/LiqvEZlMI0s\nU2LuyU2vdT+7Thn3hT1EfBYTOEuGIgXijGA4aLNAx4HsRx2M6HeLE277syJxBNgU\n3DsGix3gso9/jJjt4p5G5II=\n-----END PRIVATE KEY-----\n",
  "client_email": "gcsserviceaccountname1@ornate-shine-192301.iam.gserviceaccount.com",
  "client_id": "114270155500502944764",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://accounts.google.com/o/oauth2/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gcsserviceaccountname1%40ornate-shine-192301.iam.gserviceaccount.com"
}

3. " ":
enter image description here

4. API Google Cloud Storage:
enter image description here

:
1. gsutil GCP console.
2. Java API GCS.
3. GCP VM buckets API Java . (Update20180316)

Google Compute Engine. , , , (gcloud auth application-default login).

:
1. API
2. Cloud Storage
3.

+4
1

, , , ..

0

Source: https://habr.com/ru/post/1694665/


All Articles