首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >:无法授权任务队列API请求

:无法授权任务队列API请求
EN

Stack Overflow用户
提问于 2015-07-06 22:51:18
回答 1查看 312关注 0票数 1

所有人。

我在试图授权Compute Engine实例在任务队列中租赁任务时遇到了问题。

我在实例创建配置中包括了de必需的作用域(我认为):

代码语言:javascript
复制
    "metadata": {
    "kind": "compute#metadata",
    "items": [
      {
        "key": "startup-script-url",
        "value": "[MY-STARTUP-SCRIPT]"
      },
      {
        "key": "service_account_scopes",
        "value": "https://www.googleapis.com/auth/cloud-platform"
      }
    ]
    },
    "serviceAccounts": [
    {
      "email": "[MY-SERVICE-ACCOUNT]",
      "scopes": [
        "https://www.googleapis.com/auth/devstorage.read_only",
        "https://www.googleapis.com/auth/logging.write",
        "https://www.googleapis.com/auth/taskqueue",
        "https://www.googleapis.com/auth/cloud-platform",
        "https://www.googleapis.com/auth/compute"
      ]
    }

在我的queue.yaml中,我还将相同的服务帐户添加到带有"user_email“属性的acl指令中:

代码语言:javascript
复制
queue:
- name: [MY-QUEUELIST]
  mode: pull
  retry_parameters:
    task_retry_limit: 5
  acl:
  - user_email: [MY-COMPUTE-ENGINE-SERVICE-ACCOUNT]

最后,我在实例上运行的脚本使用GoogleCredentials.get_application_default()函数获取凭据。此凭据作为参数传递给build()方法(如此处所述:https://cloud.google.com/compute/docs/authentication):

最终的结果是,当我试图列出给定任务队列的任务时,会得到以下错误:

googleapiclient.errors.HttpError:https://www.googleapis.com/tasks/v1/lists/documentation-compiler-queue/tasks?alt=json返回“不足权限”>“

我遗漏了什么?!

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-07 23:02:36

我有自己的错误!

别管这道菜了。我用的是:

代码语言:javascript
复制
from googleapiclient.discovery import build
taskqueue_service = build('task', 'v1beta2', credentials=credentials)

而不是:

代码语言:javascript
复制
from googleapiclient.discovery import build 
taskqueue_service = build('taskqueue', 'v1beta2', credentials=credentials)

注意到构建方法中的API名称字符串

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31257030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档