Implementing SAP xsuaa service with java and deployed, accessing the application URL facing below issue.

enter image description here

2

There are 2 best solutions below

0
On

Posting this problem solution as I faced and resolved.

Case 1: If you are using BAS (Business Application Studio) and deploying through mta file, make sure you have added forwardAuthToken: true for xsuaa service associated application instance.

in the mta file add the below properties.

requires:
      - name: my_xsuaa
      - name: MY_API
        group: destinations
        properties:
          name: MY_API
          url: '~{url}'
        forwardAuthToken: true

If it is not working after that then check your xs-security.json file

"oauth2-configuration": {
        "token-validity": 604800,
        "refresh-token-validity": 2592000,
        
        "redirect-uris":[
            "https://*.<your_uri>/login/callback"
        ]  
    }

Case 2: If deploying a java application below properties should be set in the menifest.yml file.

env:
    SESSION_TIMEOUT: 30
    destinations: >
        [{
            "name":"MY_API",
            "url" :"<you_java_application_uri>",
            "forwardAuthToken": true
        }
        ]
0
On

I had the same problem while doing this sap tutorial (https://developers.sap.com/tutorials/btp-cf-buildpacks-node-create.html) and it was solved by adding the oath2-configuration to the xs-security.json:

"oauth2-configuration": {
  "token-validity": 604800,
  "refresh-token-validity": 2592000,
  "redirect-uris": [
    "https://<App-router Url>/**"
  ]
},