2

Im trying to execute a workflow from cloud tasks but getting immediately 401 error.

Here is the code to enqueue the task:

req := &taskspb.CreateTaskRequest{
    Parent: fmt.Sprintf("projects/%v/locations/us-central1/queues/myqueue", projectID),
    Task: &taskspb.Task{
        PayloadType: &taskspb.Task_HttpRequest{
            HttpRequest: &taskspb.HttpRequest{
                HttpMethod: taskspb.HttpMethod_POST,
                Url:        fmt.Sprintf("https://workflowexecutions.googleapis.com/v1/projects/%v/locations/us-central1/workflows/myworkflow/executions", projectID),
                Body:       bodyJson,
                AuthorizationHeader: &taskspb.HttpRequest_OidcToken{
                    OidcToken: &taskspb.OidcToken{
                        ServiceAccountEmail: serviceAccount,
                    },
                },
            },
        },
    },
}

_, err = client.CreateTask(ctx, req)

UNAUTHENTICATED 401 error:

enter image description here

The service account I'm using has the workflow invoker permission.

What am I missing here?

Raz Omessi
  • 1,812
  • 1
  • 14
  • 13

0 Answers0