Skip to Content
1
Aug 17, 2023 at 07:38 PM

Call SAP Build Process Automation with CAP service: error " OAuth grant cannot be propagated"

233 Views Last edit Aug 17, 2023 at 07:40 PM 2 rev

Hi colleagues,

I'm currently trying to call an SAP Build Process Automation API from CAP in order to create a Workflow instance

  async createWorkflowInstance(req, definitionId, context) {
    const service = await cds.connect.to('spa_workflow');

    return service.tx(req).post('/v1/workflow-instances', { definitionId, context });
  }<br>

and receive error in logs

The operation that you performed requires principal propagation but you are authenticated with an OAuth grant that cannot be propagated. Please perform this operation with a grant type that contains a user identity.<br>
even though my service is annotated with
service CreateRequests @(requires: 'authenticated-user') {<br>
and I'm able to see my bearer token via debugger.

The spa_workflow is

            "spa_workflow": {
                "kind": "rest",
                "credentials": {
                    "destination": "sap_process_automation_service",
                    "path": "/public/workflow/rest"
                }
            },<br>

the destination sap_process_automation_service is set as per default instruction

https://help.sap.com/docs/build-process-automation/sap-build-process-automation/configure-sap-build-process-automation-destinations

xsuaa is enabled and binded

I already tried to create a destination with type OAuth2JWTBearer - this is how I did it in the past for classical WorkflowManagement - it worked for a while but at some point I had to re-create it - now I always receive an error 401 despite my user has all workflow roles.

Do you have any ideas? Thank you in advance.