【发布时间】:2021-09-04 22:17:07
【问题描述】:
我希望就遇到的这个错误代码得到一些帮助。
上下文:
- 我工作的公司使用 GSUITE 产品。
- 我的团队有自己的云项目设置。
- Google 云端硬盘不是“个人”云端硬盘。
- 我们利用 Airflow 在 每天/每周/每月。
我已遵循这些解决方案
Access Denied: Permission denied while getting Drive credentials
"Encountered an error while globbing file pattern" error when using BigQuery API w/ Google Sheets
并且还引用了 https://cloud.google.com/bigquery/external-data-drive#python_3
问题
云作曲家:v 1.12.0
我最近设置了一个外部 Bigquery 表,用于读取 Google 表格中的标签。由于 Drive 的访问限制,我的 Airflow DAG 未能完成。 我已将以下内容添加到 Airflow 连接范围:
并且还将服务帐户电子邮件地址添加到该表通过 Share 引用的 Google 表格中。我还将服务帐户 IAM 角色更新为 BigQuery 管理员。执行这些步骤后,我仍然收到错误 BigQuery: Permission denied while getting Drive credentials。
问题2
根据上述情况,我发现在本地进行故障排除更容易,因此我在我的机器上创建了一个 VENV,因为它是我最舒服的故障排除位置。目标是简单地查询读取 Google 工作表的 Bigquery 表。但是,按照上述相同的步骤进行操作后,我仍然无法使其正常工作。
我的本地代码:
import dotenv
import pandas as pd
from google.cloud import bigquery
import google.auth
def run_BigQuery_table(sql):
dotenv.load_dotenv()
credentials, project = google.auth.default(
scopes=[
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/bigquery",
]
)
bigquery.Client(project, credentials)
output = pd.read_gbq(sql, project_id=project, dialect='standard')
return output
script_variable = "SELECT * FROM `X` LIMIT 10"
bq_output = run_BigQuery_table(script_variable)
print(bq_output)
我的错误:
提出自我._异常 google.api_core.exceptions.Forbidden: 403 Access Denied: BigQuery BigQuery: Permission denied > while getting Drive credentials.
引发 GenericGBQException("原因:{0}".format(ex)) pandas_gbq.gbq.GenericGBQException:原因:403 访问被拒绝:BigQuery BigQuery:权限 > 在获取云端硬盘凭据时被拒绝。
有人可以帮忙吗?
干杯
【问题讨论】:
标签: python google-cloud-platform google-bigquery airflow