【发布时间】:2020-06-01 20:50:11
【问题描述】:
你好,我越来越绝望了。
我正在尝试使用 Cron 和 NodeJS 脚本将数据导入 Google BigQuery。但我收到拒绝访问错误:
Access Denied: Dataset arcane-pillar-XXX:MyProj: User does not have bigquery.datasets.get permission for dataset arcane-pillar-XXX:MyProj
- 我创建了一个服务帐号 bq-data-import-user@arcane-pillar-XXX.iam.gserviceaccount.com
- 我创建了一个密钥,将其下载为 JSON 文件并设置了环境变量
- 当我在本地计算机上运行 NodeJS 脚本时出现错误。
- 我已经使用 Policy Troubleshooter 测试了该帐户。疑难解答程序说已授予权限。
我多次尝试重新创建帐户,但没有任何帮助。我已经验证没有项目不匹配,因为当我删除数据集时错误会发生变化。
有什么建议吗?
#!/usr/bin/env node
"use strict";
const {BigQuery} = require('@google-cloud/bigquery');
process.env["GOOGLE_APPLICATION_CREDENTIALS"] = "/etc/my-app/google-application-credentials.json";
const bq = new BigQuery();
const bqDataset = (await bq.dataset("TheDataset").get({ autoCreate: true }))[0]; // THIS LINE THROWS THE ERROR
const bqTable = (await bqDataset.table("TheTable").get({ autoCreate: true, schema: [ /* The BQ schema */ ] }))[0];
for await (const row of rows) { // Rows is a async generator (cursor in MySQL)
await bqTable.insert(row);
}
【问题讨论】:
标签: node.js google-cloud-platform google-bigquery google-iam