AccessDeniedException:403没有storage.buckets.get访问Google Cloud Storage存储桶

时间:2020-08-13 20:42:32

标签: firebase google-cloud-storage firebase-storage gsutil

我在这里关注Firebase的文档:https://firebase.google.com/docs/storage/web/download-files

当我开始安装gsutil并随后运行此命令时:

set cors.json gs://images/

我收到此错误

AccessDeniedException:403没有storage.buckets.get访问Google Cloud Storage存储桶

1 个答案:

答案 0 :(得分:2)

此错误是因为通过gsutil命令认证的用户没有存储管理员角色,以便能够修改存储桶的CORS配置。

作为documentation guides you on installing the full cloud SDK,我假设您已经拥有并可以使用其中的命令。

  • 首先,您需要使用以下命令登录:
gcloud auth login

按照屏幕上的说明进行操作。

  • 登录后,您需要在帐户中拥有存储管理员角色,为此,您需要知道您的Project-id,然后授予权限。因此将需要运行以下两个命令:
gcloud projects list

gcloud projects add-iam-policy-binding <PROJECT-ID> --member='user:<USER_ACCOUNT>' --role='storage.admin'

您将从第一个命令获取的项目ID。

现在您将能够运行:

set cors.json gs://images/