I made a publicly listable bucket on google cloud storage. I can see all the keys if I try to list the bucket objects in the browser. I was trying to use the create_anonymous_client()
function so that I can list the bucket keys in the python script. It is giving me an exception. I looked up everywhere and still can't find the proper way to use the function.
from google.cloud import storage
client = storage.Client.create_anonymous_client()
a = client.lookup_bucket('publically_listable_bucket')
a.list_blobs()
Exception I am getting:
ValueError: Anonymous credentials cannot be refreshed.
Additional Query: Can I list and download contents of public google cloud storage buckets using boto3
, If yes, how to do it anonymously?
In the Google Cloud console, go to the Cloud Storage Buckets page. Click on the name of the bucket that contains the object you want to make public, and navigate to the object if it's in a subdirectory.
Access public datasets in the Google Cloud console The public dataset project is pinned to every project. To view the public datasets and tables in this project, see Displaying resources. If the project is not shown, search for "bigquery-public-data" and click "Broaden search to all projects" to find this project.
I was also struggling with thing and couldn't find an answer anywhere online. Turns out you can access the bucket with just the bucket() method.
I'm not sure why, but this method can take several seconds sometimes.
client = storage.Client.create_anonymous_client()
bucket = client.bucket('publically_listable_bucket')
blobs = list(bucket.list_blobs())
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