【问题标题】:BigQuery NodeJs Library - Error while accessing external source in Google DriveBigQuery NodeJs 库 - 访问 Google Drive 中的外部源时出错
【发布时间】:2020-07-09 05:03:44
【问题描述】:

我正在尝试使用NodeJS SDK 在BigQuery 中运行查询,但我收到一条错误消息

“错误:未找到具有 Google Drive 范围的 OAuth 令牌”。

该表是一个外部表,其源格式类似于GOOGLE_SHEETS。

我使用以下代码配置了大查询,添加了额外的范围。我的默认凭据可以访问驱动器。注意:bq 命令正在运行。

const { BigQuery } = require('@google-cloud/bigquery');

const bigquery = new BigQuery({
    projectId: "my-dataset",
    scopes: [
        "https://www.googleapis.com/auth/drive.readonly"
    ],
});

我错过了什么?有人可以帮我吗?

【问题讨论】:

    标签: node.js google-cloud-platform google-bigquery node-modules


    【解决方案1】:

    根据documentation“访问托管在 Google Drive 中的数据需要额外的 OAuth 范围,无论是在定义联合源时还是在查询执行期间”。

    使用 BigQuery API 时,说明除了 BigQuery 的范围外,还需要请求 Google Drive 的 OAuth 范围。在上述链接中,您还将找到以其他语言显式创建具有所需范围的凭据的示例。

    为了方便起见,我建议您使用Google Auth Library,包括作为作用域:

    scopes: [
        "https://www.googleapis.com/auth/drive.readonly",
        "https://www.googleapis.com/auth/bigquery"
        ]
    

    【讨论】:

      猜你喜欢
      • 2014-11-05
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多