没有获取App Script访问BigQuery Service的授权对话框 [英] Not getting Authorization dialog for App Script accessing BigQuery Service

查看:127
本文介绍了没有获取App Script访问BigQuery Service的授权对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修复一些使用BigQuery高级服务的App脚本来安装一些BigQuery作业。我运行的第一个新脚本弹出一个BigQuery授权对话框,一切正常,现在每小时运行一次。第二个新脚本最初运行,但现在失败:

  {
error:{
错误:[
{
domain:global,
reason:required,
message:需要登录,
locationType:header,
location:Authorization
}
],
code:401,
message: 需要登录
}
}

初始授权,所以它看起来像过期了。但是,我无法弄清楚如何触发授权对话框出现。另外,我预计每个独立函数都需要授权,但第二个函数最初并没有要求BigQuery权限。



附加信息:
这里是我正在执行的.gs文件:

  function runQuery(){
var projectId = redacted;

var query = {
useQueryCache:false,
destinationTable:{
projectId:projectId,
datasetId:redacted,
tableId:redacted
},
writeDisposition:WRITE_TRUNCATE,
createDisposition:CREATE_IF_NEEDED,
allowLargeResults:true,
query:redacted
}
};
var job = {
configuration:configuration
};

var jobResult = BigQuery.Jobs.insert(job,projectId);
var jobId = jobResult.jobReference.jobId;
Logger.log(jobResult);
}

第一次运行一个非常类似的查询时,我得到一个对话框提示我对于BigQuery权限,请参阅以下文档:
https://开发人员。 google.com/apps-script/guides/services/authorization
我随后成功地运行了这个脚本(使用略有不同的查询配置)。但是,第一次运行约12小时后,我开始获得上面引用的授权返回。我认为它可能会随着时间的推移而更新,但仍然会有同样的失败。

解决方案

原来这一直在一直工作。授权错误是由于我试图查看工作结果而不是工作本身而产生的。 Doh!

I am trying to fix some App Scripts which use the BigQuery "Advanced Service" to install some BigQuery jobs. The first new script I ran popped a BigQuery authorization dialog, and everything worked fine, now running hourly. The second new script ran initially, but is now failing with:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Login Required",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Login Required"
 }
}

This began about 12 hours after the initial authorization, so it seems like something expired. But, I can't figure out how to trigger the authorization dialog to appear. Also, I expected an authorization would be required for each distinct function, yet the second one initially ran without asking for BigQuery permissions.

Additional Info: Here is the .gs file I am executing:

function runQuery() {
  var projectId = redacted;

  var configuration = {
    "query": {
      "useQueryCache": false,
      "destinationTable": {
          "projectId": projectId,
          "datasetId": redacted,
          "tableId": redacted
        },
      "writeDisposition": "WRITE_TRUNCATE",
      "createDisposition": "CREATE_IF_NEEDED",
      "allowLargeResults": true,
      "query": redacted
    }
  };
  var job = {
    "configuration": configuration
  };

  var jobResult = BigQuery.Jobs.insert(job, projectId);
  var jobId = jobResult.jobReference.jobId;
  Logger.log(jobResult);
}

The first time I ran a very similar query, I got a dialog prompting me for BigQuery permissions, as documented here: https://developers.google.com/apps-script/guides/services/authorization I subsequently ran this same script successfully (with slightly different query config). But, then, about 12 hours after first run, I started getting the authorization return quoted above. I thought it might refresh with time, but still get same failure.

解决方案

Turns out this has been working all along. The authorization error was being generated by my attempt to look at the job results, not by the job itself. Doh!

这篇关于没有获取App Script访问BigQuery Service的授权对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆