user395882
user395882

Reputation: 665

Issue in accessing google storage bucket

I am using two GCP accounts, I setup a google cloud sdk and accessed GS bucket from account 1. Now I would like to access another GS bucket which is mapped to another account and when I run the command

client.get_bucket(bucket)

It says 403 GET https://storage.googleapis.com/storage/v1/b/agencyq-bucket?projection=noAcl&prettyPrint=false: does not have storage.buckets.get access to the Google Cloud Storage bucket.

Upvotes: 0

Views: 427

Answers (1)

masaya
masaya

Reputation: 490

I think there are 2 opitions we can take.
One is to add storage.buckets.get access by adding Storage Legacy Bucket Reader Role.
(Or add another role that has storage.buckets.get ).

The other is to change the code as follows:

# Don't Use get_bucket() because it needs storage.buckets.get
# Use client.bucket() Insted.
# client.get_bucket(bucket)
your_bucket = client.bucket(bucket)

# then use bucket
your_blob = your_bucket.blob( known_blob_path)
your_blob.download_to_filename(known_object_path)

Upvotes: 1

Related Questions