sapui5saml-2.0sap-fiorisap-business-technology-platformsap-cloud-identity-services

How to get Authentication Service user account info in front-end?


I am building a HTML5 application in SCP, using Portal Service to manage roles. Back-end developer asked me to give them role info (ID or e-mail) as an input of an interface (They need this authentication info). How to get it?

Is there any front-end API provided to get these info?


Solution

  • User API provides few details about user in HCP. To use the user API in your HTML5 application, add a route to your neo-app.json application descriptor file as follows:

    "routes": [
       {
         "path": "/services/userapi", //application path to be forwarded
         "target": {
           "type": "service",
           "name": "userapi"
         }
      }
    ]
    

    A sample URL for the route defined above would look like this: /services/userapi/currentUser.

    An example response could return the following user data:

    {
      "name": "p12345678",
      "firstName": "Jon",
      "lastName": "Snow",
      "email": "jon.snow@tina.com",
      "displayName": "Jon Snow (p12345678)"
    }
    

    More info here