How to setup Authorization when custom authentication is used

I am using the custom authentication mechanism and setting the Authentication as below.

engine.getIdentityService().setAuthentication(username, groupNames, Arrays.asList(tenant));

Now when I am trying to complete a User Task then I get the below error. How to set Authorization here.

WARN [,fc5506cdf3b8da46,fc5506cdf3b8da46,true] 67910 --- [nio-8080-exec-8]    : ENGINE-REST-HTTP500 Cannot complete task 681a456b-45d7-11ec-9bee-32a1803f1a52: ENGINE-03051 There was an exception while invoking the TaskListener. Message: 'Authorization must either have a 'userId' or a 'groupId'.'

Hi @Himanshu_Singh
You can configure authorization with Authorization (Camunda Platform Javadocs 7.16.1-ee)

Hi @Himanshu_Singh,

in the end the process engine expects an authenticated user.

The api call is


Hope this helps, Ingo