1
votes

everyone.

I'm having trouble trying to authorize my Compute Engine instance to lease tasks on a Task Queue queue.

I've included de necessary scopes (I think), in the instance creation config:

    "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"
      ]
    }

Also in my queue.yaml, I have added the same service account to the acl directive with the "user_email" attribute:

queue:
- name: [MY-QUEUELIST]
  mode: pull
  retry_parameters:
    task_retry_limit: 5
  acl:
  - user_email: [MY-COMPUTE-ENGINE-SERVICE-ACCOUNT]

Finally, the script that I run on my instance uses the GoogleCredentials.get_application_default() function to obtain the credentials. This credentials are passed as argument to the build() method (as stated here: https://cloud.google.com/compute/docs/authentication):

The end result is that when I try to list the task of the given taskqueue I get this error:

googleapiclient.errors.HttpError: https://www.googleapis.com/tasks/v1/lists/documentation-compiler-queue/tasks?alt=json returned "Insufficient Permission">

What am I missing?!

Thanks in advance.

1

1 Answers

1
votes

I got my own mistake!

Just ignore this cuestion. I was using:

from googleapiclient.discovery import build
taskqueue_service = build('task', 'v1beta2', credentials=credentials)

instead of:

from googleapiclient.discovery import build 
taskqueue_service = build('taskqueue', 'v1beta2', credentials=credentials)

Note the [API name] string in the build method