0
votes

Good day,

I am new to GCS and trying to access a partner's bucket using CLI. I have installed gsutil using documentation provided here (NOTE: I'm using macOS) and now I am trying to list files within a bucket. Access id key and secret have been provided which I use them to create a config file using:

gsutil config -a

which outputs:

Boto config file "/path/to/.boto" created. If you need to
use a proxy to access the Internet please see the instructions in that
file.

However, when I use the following command to list files within a bucket:

gsutil ls gs://bucket-name

It says:

AccessDeniedException: 403 [email protected] does not have storage.objects.list access to the Google Cloud Storage bucket.

I think it's probably because of a sign in that I did as part of initializing google cloud using:

gcloud init

I'm wondering if there is a way to force ls command to use stored credentials instead of my email address and login that I did earlier. Any help is much appreciated.

3
Check if you are logged in as a user who has permision to the files/bucketJ.Wincewicz

3 Answers

1
votes

So here is what fixed the issue for me on my laptop. I ran this first:

gcloud config set pass_credentials_to_gsutil false

And then the ls command would work just fine. What is strange to me is that adding / to the original ls command that I posted fixed the issue on another instance:

gsutil ls gs://bucket-name/
0
votes

hello you can try with npm

try npm i @google-cloud/storage

https://www.npmjs.com/package/@google-cloud/storage

0
votes

I'm wondering if there is a way to force ls command to use stored credentials instead of my email address and login that I did earlier

  1. Create a service account with necessary permission (ex Storage Admin roles/storage.admin)

  2. Run gsutil config -e and insert the full path to your private key file

  3. Run the gsutil ls command, and gsutil will use the service account credentials.

config - Obtain credentials and create configuration file