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:
The service account I'm using has the workflow invoker permission.
What am I missing here?