Google cloud get bucket-使用cli,但不能在python中使用

问题描述 投票:0回答:2

我被要求与外部google存储桶进行集成,我收到了凭证json,

而在尝试做gsutil ls gs://bucket_name(使用creds json配置自己后),以及尝试将文件上传到存储桶时,我都收到了有效的回复。

[当尝试使用Python3时,它不起作用:

[虽然使用google-cloud-storage==1.16.0(也尝试了较新的版本),但我正在这样做:

project_id = credentials_dict.get("project_id")
credentials = service_account.Credentials.from_service_account_info(credentials_dict)
client = storage.Client(credentials=credentials, project=project_id)

bucket = client.get_bucket(bucket_name)

但是在get_bucket行上,我得到:

google.api_core.exceptions.Forbidden: 403 GET https://www.googleapis.com/storage/v1/b/BUCKET_NAME?projection=noAcl: USERNAME@PROJECT_ID.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket.

与我集成的外部合作伙伴,说用户设置正确,并证明他们在显示我可以gsutil执行操作。

您能帮忙吗?知道可能是什么问题吗?

python python-3.x google-cloud-storage gsutil
2个回答
0
投票
[请按照these steps正确设置Python的Cloud Storage客户端库。通常,云存储库可以使用Application default credentials or environment variables for authentication

0
投票
答案是,信用确实是错误的,但是当我尝试在客户端client.bucket(bucket_name)而非client.get_bucket(bucket_name)上执行时,它确实起作用了。
© www.soinside.com 2019 - 2024. All rights reserved.