在 Bigquery 上从命令行客户端执行时出现 403 权限错误
403 permission error when executing from command line client on Bigquery
我在我的本地系统中设置了 gcloud,我正在使用 python3.7 将记录插入位于 projectA 中的大查询数据集中。所以我从 命令行客户端 尝试将项目设置为 projectA。我给出的第一个命令是进行身份验证
gcloud auth login
然后我使用 python3 并进入 python 模式
然后我给出以下命令
from googleapiclient.discovery import build
from google.cloud import bigquery
import json
body={json input} //pass the json string here
bigquery = build('bigquery', 'v2', cache_discovery=False)
bigquery.tabledata().insertAll(projectId="projectA",datasetId="compute_reports",tableId="compute_snapshot",body=body).execute()
我收到这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/googleapiclient/http.py", line 915, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://bigquery.googleapis.com/bigquery/v2/projects/projectA/datasets/compute_reports/tables/compute_snapshot/insertAll?alt=json returned "Access Denied: Table projectA:compute_reports.compute_snapshot: User does not have bigquery.tables.updateData permission for table projectA:compute_reports.compute_snapshot."
我正在以具有项目的 role/Owner 和 BigQueryDataOwner 权限的用户身份执行它,并将 DataEditor 添加到数据集也具有这些权限,包括
bigquery.tables.update
bigquery.datasets.update
我仍然收到此错误。
我不明白为什么我的凭据仍然无法在大查询中执行插入,有人可以帮忙吗?谢谢
错误出在权限上,所以 python 运行 时使用的服务帐户,是 bash 配置文件中设置的默认服务帐户没有 projectA 的 Bigquery 数据编辑器访问权限。一旦我授予访问权限,它就开始工作了
我在我的本地系统中设置了 gcloud,我正在使用 python3.7 将记录插入位于 projectA 中的大查询数据集中。所以我从 命令行客户端 尝试将项目设置为 projectA。我给出的第一个命令是进行身份验证
gcloud auth login
然后我使用 python3 并进入 python 模式
然后我给出以下命令
from googleapiclient.discovery import build
from google.cloud import bigquery
import json
body={json input} //pass the json string here
bigquery = build('bigquery', 'v2', cache_discovery=False)
bigquery.tabledata().insertAll(projectId="projectA",datasetId="compute_reports",tableId="compute_snapshot",body=body).execute()
我收到这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/googleapiclient/http.py", line 915, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://bigquery.googleapis.com/bigquery/v2/projects/projectA/datasets/compute_reports/tables/compute_snapshot/insertAll?alt=json returned "Access Denied: Table projectA:compute_reports.compute_snapshot: User does not have bigquery.tables.updateData permission for table projectA:compute_reports.compute_snapshot."
我正在以具有项目的 role/Owner 和 BigQueryDataOwner 权限的用户身份执行它,并将 DataEditor 添加到数据集也具有这些权限,包括 bigquery.tables.update bigquery.datasets.update
我仍然收到此错误。
我不明白为什么我的凭据仍然无法在大查询中执行插入,有人可以帮忙吗?谢谢
错误出在权限上,所以 python 运行 时使用的服务帐户,是 bash 配置文件中设置的默认服务帐户没有 projectA 的 Bigquery 数据编辑器访问权限。一旦我授予访问权限,它就开始工作了