【问题标题】:User does not have bigquery.datasets.update permission用户没有 bigquery.datasets.update 权限
【发布时间】:2020-04-04 13:01:04
【问题描述】:

我在 Google BigQuery 中创建了一个数据集并下载了 json 身份验证文件。我正在尝试从 Jupyter Notebook 中的 python 访问此数据集中的表,但出现错误:

“禁止:403 PATCH https://bigquery.googleapis.com/bigquery/v2/projects/testdbt-bigquery-20200403/datasets/landing_zone_flights:访问被拒绝:数据集 testdbt-bigquery-20200403:landing_zone_flights:用户没有数据集 testdbt-bigquery-20200403:landing_zone_flights 的 bigquery.datasets.update 权限。”

代码:

%reload_ext google.cloud.bigquery

import os
from google.cloud import bigquery
print(os.environ['GOOGLE_APPLICATION_CREDENTIALS']) 
client = bigquery.Client.from_service_account_json('~/Code/BigQuery/Test_BQ.json')
#get dataset and set permissions as Reader
dataset = client.get_dataset("landing_zone_flights")
entries = list(dataset.access_entries)
full_dataset_id = "{}.{}".format(dataset.project, dataset.dataset_id)
dataset.access_entries = entries

dataset = client.update_dataset(dataset, ["access_entries"])  # Make an API request.

print(
    "Updated dataset '{}' with modified user permissions.".format(full_dataset_id)
)

错误是:

禁止:403 补丁 https://bigquery.googleapis.com/bigquery/v2/projects/testdbt-bigquery-20200403/datasets/landing_zone_flights: 拒绝访问:数据集 testdbt-bigquery-20200403:landing_zone_flights: 用户没有数据集的 bigquery.datasets.update 权限 testdbt-bigquery-20200403:landing_zone_flights .

我做错了什么?我能够获取并列出数据集属性,但无法更新或查询任何表

【问题讨论】:

    标签: python google-bigquery


    【解决方案1】:

    我能够通过创建一个角色为 Project - Owner 而不是 BigQuery - Reader 的新密钥来解决此问题

    【讨论】:

      【解决方案2】:

      如果您想在 Bigquery 数据集中使用更精细的方法来允许更新,您可以使用以下规则:

      1. bigquery.datasets.create
      2. bigquery.datasets.delete
      3. bigquery.datasets.update
      4. bigquery.datasets.get

      there 中提到了此预定义角色。

      【讨论】:

        【解决方案3】:
        1. 转到this Google Cloud link

        2. 转到谷歌控制台

        3. 将项目的权限从“编辑”更改为“所有者”。

        4. 按照最新的说明进行操作,但在撰写本文时,我已使用 IAM 角色来更改权限。

        这对我有用

        【讨论】:

          猜你喜欢
          • 2020-10-08
          • 1970-01-01
          • 2019-09-19
          • 1970-01-01
          • 2013-09-29
          • 2018-08-30
          • 1970-01-01
          • 1970-01-01
          • 2021-02-03
          相关资源
          最近更新 更多