为什么我在尝试访问我的 google 云存储桶时收到 403 错误?

Why am I getting a 403 error when attempting to access my google cloud bucket?

我在 url 有一个水桶,类似于:https://console.developers.google.com/storage/browser/gdfp-1234/

然后我创建了一个项目,命名为 'api-required' 这样我就可以在 /apis/credentials?project=api-required

生成凭据

然后,我使用 /api/credentials/ 上的 new_credentials 按钮生成了一个 json 服务帐户密钥。我将下载的 json 对象保存到我将环境变量 GOOGLE_APPLICATION_CREDENTIALS 指向的文件中。

现在,我正在 python 中构建一个应用程序。此代码:

from gcloud import storage

gcs = storage.Client(project='my client n')
bucket = gcs.get_bucket(bucket_name)

给我一个 403 Forbidden 错误。

Google Cloud Storage JSON API 在 API 管理器的已启用 API 列表中。这似乎涵盖了文档中的所有内容。

我一直在研究文档,终究无法弄清楚我做错了什么。如果您能帮助解决这个问题,我们将不胜感激,谢谢!

编辑:
这是回溯:

/Users/asdf/.virtualenvs/analytics_pipeline/lib/python2.7/site-packages/gcloud/storage/client.pyc in get_bucket(self, bucket_name)
    165         """
    166         bucket = Bucket(self, name=bucket_name)
--> 167         bucket.reload(client=self)
    168         return bucket
    169 

/Users/asdf/.virtualenvs/analytics_pipeline/lib/python2.7/site-packages/gcloud/storage/_helpers.pyc in reload(self, client)
     75         api_response = client.connection.api_request(
     76             method='GET', path=self.path, query_params=query_params,
---> 77             _target_object=self)
     78         self._set_properties(api_response)
     79 

/Users/asdf/.virtualenvs/analytics_pipeline/lib/python2.7/site-packages/gcloud/connection.pyc in api_request(self, method, path, query_params, data, content_type, api_base_url, api_version, expect_json, _target_object)
    335         if not 200 <= response.status < 300:
    336             raise make_exception(response, content,
--> 337                                  error_info=method + ' ' + url)
    338 
    339         string_or_bytes = (six.binary_type, six.text_type)

所以我所属的 google 组可以访问该存储桶,并且该存储桶是由 DFP 创建的,因为该存储桶中装满了 DFP 数据传输 Files/Reports。要访问他们的存储桶,我必须将在我下载的 json 文件中找到的电子邮件添加到 google 组(使用添加成员直接按钮,而不是邀请按钮)。一旦我将它们添加到 google 组,一切都非常顺利。