【问题标题】:BigQuery - script-run queries on GSheet tables don't workBigQuery - GSheet 表上的脚本运行查询不起作用
【发布时间】:2018-02-16 07:14:54
【问题描述】:

我的一些 BQ 表从 GSheets 获取数据。 但是,一旦我从 Apps 脚本对这些表运行查询,我就会收到此错误:

Access Denied: BigQuery BigQuery: No OAuth token with Google Drive scope was found. 

错误是指这行代码:

var queryResults = BigQuery.Jobs.query(request, projectId);

在我的 BigQuery 界面(查询历史记录)中,我可以看到不成功的请求,当我从那里重新运行它时,我得到了结果,一切正常。

知道如何使用脚本运行查询吗?

谢谢

【问题讨论】:

标签: authentication google-apps-script google-bigquery


【解决方案1】:

根据遇到的错误,在使用BigQuery Service之前尝试enable advanced services

另外,正如Advanced Google Services 中提到的,

Apps 脚本自动处理authorization flow,但默认情况下未启用。

请参阅Big Query And Google Spreadsheet Integration 了解更多见解。

希望对您有所帮助。

【讨论】:

  • BigQuery 服务已启用,只要不涉及 GSheets-BQ 表,脚本就可以正常工作
【解决方案2】:

正如 Google 支持在 https://issuetracker.google.com/issues/65654399 中指出的那样,确保存在所需范围的推荐方法是在代码中添加以下内容:

// Forces the script to require
// https://www.googleapis.com/auth/drive.readonly scope.
// DriveApp.getFiles();

为了强调,DriveApp.getFiles(); call 可以放在评论里。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-28
    • 1970-01-01
    • 1970-01-01
    • 2018-12-21
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 2023-04-02
    相关资源
    最近更新 更多