title: PERMISSION_DENIED error when trying to run a Google Cloud Scheduler task
body: <p>I have a Google Cloud Function consisting of a Python script. When I test the function everything works as expected.</p>
  <p>The function uses a PubSub as trigger and a service account. I've setup a Cloud Sheduler to trigger the PubSub daily. But when I test the Scheduler by using the &quot;run now&quot; button I get this permission denied error.</p>
  <pre><code>{
    &quot;insertId&quot;: &quot;***&quot;,
    &quot;jsonPayload&quot;: {
      &quot;status&quot;: &quot;PERMISSION_DENIED&quot;,
      &quot;pubsubTopic&quot;: &quot;projects/***/topics/***&quot;,
      &quot;@type&quot;: &quot;type.googleapis.com/google.cloud.scheduler.logging.AttemptFinished&quot;,
      &quot;targetType&quot;: &quot;PUB_SUB&quot;,
      &quot;jobName&quot;: &quot;projects/***/locations/europe-west1/jobs/***&quot;
    },
    &quot;resource&quot;: {
      &quot;type&quot;: &quot;cloud_scheduler_job&quot;,
      &quot;labels&quot;: {
        &quot;project_id&quot;: &quot;***&quot;,
        &quot;location&quot;: &quot;europe-west1&quot;,
        &quot;job_id&quot;: &quot;***&quot;
      }
    },
    &quot;timestamp&quot;: &quot;2021-06-27T21:45:00.807387936Z&quot;,
    &quot;severity&quot;: &quot;ERROR&quot;,
    &quot;logName&quot;: &quot;projects/***/logs/cloudscheduler.googleapis.com%2Fexecutions&quot;,
    &quot;receiveTimestamp&quot;: &quot;2021-06-27T21:45:00.807387936Z&quot;
  }
  </code></pre>
  <p>The Scheduler setup:
  <a href="https://i.stack.imgur.com/eNBps.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eNBps.png" alt="enter image description here" /></a></p>
  <p>My Service account has editor rights on the project. How do I know which permission is missing and where to add it? Or is the issue not the Service account but something else?</p>