获取匿名调用者在数据流上运行 wordcount 时没有 storage.objects.create 访问错误

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

我正在使用 python 运行 apache beam 包中的 wordcount 模块的数据流快速入门。我能够在我的机器上本地运行它。但是,当我尝试通过在运行程序字段中指定数据流运行程序来在数据流服务上运行它时,它会抛出错误:


 raise exceptions.HttpError.FromResponse(http_response)
RuntimeError: apitools.base.py.exceptions.HttpUnauthorizedError: HttpError accessing <https://www.googleapis.com/resumable/upload/storage/v1/b/hogwarts/o?alt=json&name=results%2Fbeam-temp-outputs-acb95dc89b0511eb9507185e0fbdf17c%2Fc5994362-a8ca-45cc-a375-85fafb619329.outputs&uploadType=resumable>: response: <{'x-guploader-uploadid': 'ABg5-UzsW55q9DUiXsssbR3c0I_X85oFxjAo-FFn_ZeZ3HtZdlWPXjcd1-euaquMiOw4znDrIl8qYkBeIOBUhUlBibI', 'date': 'Sun, 11 Apr 2021 20:37:04 GMT', 'vary': 'Origin, X-Origin', 'www-authenticate': 'Bearer realm="https://accounts.google.com/"', 'cache-control': 'no-cache, no-store, max-age=0, must-revalidate', 'expires': 'Mon, 01 Jan 1990 00:00:00 GMT', 'pragma': 'no-cache', 'content-length': '600', 'server': 'UploadServer', 'content-type': 'text/html; charset=UTF-8', 'alt-svc': 'h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"', 'status': '401'}>, content <{
  "error": {
    "code": 401,
    "message": "Anonymous caller does not have storage.objects.create access to hogwarts/results/beam-temp-outputs-acb95dc89b0511eb9507185e0fbdf17c/c5994362-a8ca-45cc-a375-85fafb619329.outputs.",
    "errors": [
      {
        "message": "Anonymous caller does not have storage.objects.create access to hogwarts/results/beam-temp-outputs-acb95dc89b0511eb9507185e0fbdf17c/c5994362-a8ca-45cc-a375-85fafb619329.outputs.",
        "domain": "global",
        "reason": "required",
        "locationType": "header",
        "location": "Authorization"
      }
    ]
  }
}

当我尝试在 google cloud sdk 中运行此代码时出现此错误:-

python -m apache_beam.examples.wordcount \ --region $REGION \ --input gs://dataflow-samples/shakespeare/kinglear.txt \ --output gs://hogwarts/results/outputs \--runner DataflowRunner \ --project MyProject1 \ --temp_location gs://hogwarts/tmp/ 

您能告诉我如何解决这个问题吗?我已经提供了所需的访问权限,并且还使用相应的密钥更新了我的 GOOGLE 应用程序凭据。

python google-cloud-platform apache-beam dataflow
2个回答
0
投票

在本地计算机上,您需要运行命令来设置默认应用程序凭据,您的情况未设置这些凭据。您很可能使用自己的帐户登录,但应用程序不使用它。您需要另外运行此命令:

gcloud auth application-default login

有关此内容的更多信息,请访问设置应用程序默认凭据


-1
投票

您需要将

storage.objects.create
上的
gs://hogwarts
授予计算服务帐户。您可以在 GCP 控制台的 IAM 部分找到它。

计算帐户如下所示:

[email protected]
,其中
xxxxxxx
是您的项目编号。

© www.soinside.com 2019 - 2024. All rights reserved.