【问题标题】:List files in Google Cloud Storage throws: AccessDeniedException: 403列出 Google Cloud Storage 中的文件抛出:AccessDeniedException:403
【发布时间】:2021-03-07 13:11:09
【问题描述】:

早安,

我是 GCS 新手,正在尝试使用 CLI 访问合作伙伴的存储桶。我已经使用here 提供的文档安装了 gsutil(注意:我使用的是 macOS),现在我正在尝试列出存储桶中的文件。已经提供了访问 ID 密钥和秘密,我使用它们来创建配置文件:

gsutil config -a

哪个输出:

Boto config file "/path/to/.boto" created. If you need to
use a proxy to access the Internet please see the instructions in that
file.

但是,当我使用以下命令列出存储桶中的文件时:

gsutil ls gs://bucket-name

上面写着:

AccessDeniedException: 403 myemail@domain.com does not have storage.objects.list access to the Google Cloud Storage bucket.

我认为这可能是因为我在初始化谷歌云时使用了以下登录:

gcloud init

我想知道是否有办法强制ls 命令使用存储的凭据,而不是我之前所做的电子邮件地址和登录。非常感谢任何帮助。

【问题讨论】:

  • 检查您是否以具有文件/存储桶权限的用户身份登录

标签: google-cloud-platform google-cloud-storage gcloud gsutil


【解决方案1】:

你好,你可以试试 npm

试试 npm i @google-cloud/storage

https://www.npmjs.com/package/@google-cloud/storage

【讨论】:

    【解决方案2】:

    我想知道是否有办法强制 ls 命令使用存储的凭据,而不是我之前使用的电子邮件地址和登录名

    1. 创建一个具有必要权限的服务帐户(例如 Storage Admin roles/storage.admin

    2. 运行 gsutil config -e 并插入您的私钥文件的完整路径

    3. 运行gsutil ls 命令,gsutil 将使用服务帐户凭据。

    config - Obtain credentials and create configuration file

    【讨论】:

      【解决方案3】:

      这就是我在笔记本电脑上解决问题的方法。我先运行了这个:

      gcloud config set pass_credentials_to_gsutil false
      

      然后ls 命令就可以正常工作了。对我来说奇怪的是,将 / 添加到我发布的原始 ls 命令修复了另一个实例上的问题:

      gsutil ls gs://bucket-name/
      

      【讨论】:

        猜你喜欢
        • 2020-12-03
        • 1970-01-01
        • 2019-06-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多