Search code examples
google-cloud-platformgoogle-cloud-scheduler

Unable to create a scheduler using the @google-cloud/scheduler package


GOT this error while creating a scheduler , earlier i got the code on local and it was working but when i deployed the code on vm on gcp itself it started failing and showed this error.

Error: 7 PERMISSION_DENIED: Request had insufficient authentication scopes.
    at Object.callErrorFromStatus (/app/node_modules/@grpc/grpc-js/build/src/call.js:31:26)


    at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client.js:180:52)
    at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141)
    at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)`enter code here`
    at /app/node_modules/@grpc/grpc-js/build/src/call-stream.js:160:78
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  code: 7,
  details: 'Request had insufficient authentication scopes.',
  metadata: Metadata {
    internalRepr: Map {
      'google.rpc.errorinfo-bin' => [Array],
      'grpc-status-details-bin' => [Array],
      'grpc-server-stats-bin' => [Array]
    },
    options: {}
  },
  statusDetails: [
    ErrorInfo {
      metadata: [Object],
      reason: 'ACCESS_TOKEN_SCOPE_INSUFFICIENT',
      domain: 'googleapis.com'
    }
  ],
  reason: 'ACCESS_TOKEN_SCOPE_INSUFFICIENT',
  domain: 'googleapis.com',
  errorInfoMetadata: {
    service: 'cloudscheduler.googleapis.com',
    method: 'google.cloud.scheduler.v1.CloudScheduler.CreateJob'`enter code here`
  }
}

Solution

  • If you use the default service account on your compute instance, you have to update the scopes; add all or only the Cloud Scheduler one.

    If you don't use the default service account, you haven't scopes to select (scopes selection is a legacy mode, no longer available with new feature).

    Note You have to stop the VM, change the scopes/service account and then restart the VM