所有人。
我在试图授权Compute Engine实例在任务队列中租赁任务时遇到了问题。
我在实例创建配置中包括了de必需的作用域(我认为):
"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指令中:
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返回“不足权限”>“
我遗漏了什么?!
提前谢谢。
发布于 2015-07-07 23:02:36
我有自己的错误!
别管这道菜了。我用的是:
from googleapiclient.discovery import build
taskqueue_service = build('task', 'v1beta2', credentials=credentials)而不是:
from googleapiclient.discovery import build
taskqueue_service = build('taskqueue', 'v1beta2', credentials=credentials)注意到构建方法中的API名称字符串
https://stackoverflow.com/questions/31257030
复制相似问题