title: Google Compute Engine: Can't authorize request to Task Queue API
body: <p>everyone.</p>
  
  <p>I'm having trouble trying to authorize my Compute Engine instance to lease tasks on a Task Queue queue.</p>
  
  <p>I've included de necessary scopes (I think), in the instance creation config:</p>
  
  <pre><code>    "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"
        ]
      }
  </code></pre>
  
  <p>Also in my queue.yaml, I have added the same service account to the acl directive with the "user_email" attribute:</p>
  
  <pre><code>queue:
  - name: [MY-QUEUELIST]
    mode: pull
    retry_parameters:
      task_retry_limit: 5
    acl:
    - user_email: [MY-COMPUTE-ENGINE-SERVICE-ACCOUNT]
  </code></pre>
  
  <p>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: <a href="https://cloud.google.com/compute/docs/authentication" rel="nofollow">https://cloud.google.com/compute/docs/authentication</a>):</p>
  
  <p>The end result is that when I try to list the task of the given taskqueue I get this error:</p>
  
  <blockquote>
    <p>googleapiclient.errors.HttpError: https://www.googleapis.com/tasks/v1/lists/documentation-compiler-queue/tasks?alt=json
    returned "Insufficient Permission"></p>
  </blockquote>
  
  <p>What am I missing?!</p>
  
  <p>Thanks in advance.</p>