我被要求与外部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
执行操作。
您能帮忙吗?知道可能是什么问题吗?
client.bucket(bucket_name)
而非client.get_bucket(bucket_name)
上执行时,它确实起作用了。