使用不带凭据的Python Google存储客户端
我使用的是,但是我使用的是具有公共读/写访问权限的存储桶。(我知道这通常是一个糟糕的想法,但我有一个罕见的用例,它很好) 当我尝试检索某些文件时,会出现使用不带凭据的Python Google存储客户端,python,google-cloud-platform,google-cloud-storage,bucket,Python,Google Cloud Platform,Google Cloud Storage,Bucket,我使用的是,但是我使用的是具有公共读/写访问权限的存储桶。(我知道这通常是一个糟糕的想法,但我有一个罕见的用例,它很好) 当我尝试检索某些文件时,会出现defaultcredentialsrerror BUCKET_NAME = 'my-public-bucket-name' storage_client = storage.Client() bucket = storage_client.get_bucket(BUCKET_NAME) def list_blobs(prefix, delim
defaultcredentialsrerror
BUCKET_NAME = 'my-public-bucket-name'
storage_client = storage.Client()
bucket = storage_client.get_bucket(BUCKET_NAME)
def list_blobs(prefix, delimiter=None):
blobs = bucket.list_blobs(prefix=prefix, delimiter=delimiter)
print('Blobs:')
for blob in blobs:
print(blob.name)
具体错误如下:
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
该页面建议使用誓言或其他标记,但我不需要这些,因为我的桶是公开的?我可以向chrome中的bucket发出HTTP请求并接收数据
我应该如何回避这个问题?我可以提供默认或空凭据吗?来自“”:
您在云存储中执行的大多数操作都必须经过身份验证。唯一的例外是允许匿名访问的对象上的操作。如果allUsers
组具有READ
权限,则可以匿名访问对象。alluser
组包括互联网上的任何人
除了错误发生在
storage\u client=storage.client()
中之外,了解该错误很有用,因此即使allUsers处于读取状态,也没有关于如何更新问题中doe的建议。我不确定该答案是否回答了问题。