cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch user details (country) from IAS in the approuter

Altarkawi
Participant
0 Kudos
49

Hello SAP Community, 

I am working on a Cloud Foundry Approuter in SAP BTP and have the following custom middleware code:

 

const approuter = require('@sap/approuter');

const ar = approuter();

ar.beforeRequestHandler.use('/', function (req, res, next) {
    if (req.url.includes('/sap/opu/odata/MY_SERVICE/')) {
        req.headers.email_user = req.user.name;
        console.log("username");
        console.log(req.user.name);
        console.log("headers");
        console.log(req.headers);
        console.log("req");
        console.log(req);
    }
    
    next();
});

ar.start();

 

 

In this setup, I am trying to retrieve the country of the authenticated user. I know the user's email is accessible via req.user.name and I have also found the JWT Access Token in the request. However, the token does not include any region or country information.

Since country information is maintained in SAP IAS (Identity Authentication Service), I’m wondering:

  • Is it possible to retrieve the country of the user from the req object or its associated JWT token?
  • If not, what would be the recommended approach to fetch country information from IAS in an SAP BTP App Router application?

Any pointers or advice would be greatly appreciated!

Thanks in advance!
Mohammed



Accepted Solutions (0)

Answers (0)