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

3.8k Views Asked by At

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?

1

There are 1 best solutions below

2
Sunil B N On BEST ANSWER

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": "[email protected]",
  "displayName": "Jon Snow (p12345678)"
}

More info here