Skip to Content

SAP HCP provides a service which can be used to obtain user information as well as log off the user.  The details regarding the userapi can be found at

Here’s two simple examples on how this can be acheived within SAP Web IDE.

Adding the User Details to a View

Add a route into the neo-app.json to reference the userapi

        "path": "/services/userapi",
        "target": {
            "type": "service",
            "name": "userapi"

Create a json model to call the service

var userModel = new sap.ui.model.json.JSONModel("/services/userapi/currentUser");
sap.ui.getCore().setModel(userModel, "userapi");

Now within a view create some fields to display the data returned by the service

<Label text="User Name"></Label>
<Text xmlns="sap.m" text="{userapi>/name}"></Text>
<Label text="First Name"></Label>
<Text xmlns="sap.m" text="{userapi>/firstName}"></Text>
<Label text="Last Name"></Label>
<Text xmlns="sap.m" text="{userapi>/lastName}"></Text>
<Label text="Display Name"></Label>
<Text xmlns="sap.m" text="{userapi>/displayName}"></Text>
<Label text="Email"></Label>
<Text xmlns="sap.m" text="{userapi>/email}"></Text>

Adding a Logout Button to Your Application

In a view add a button to call a function

<Button xmlns="sap.m" text="Log Out" press="logUserOut"></Button>

Within the corresponding controller add the function to process the event.

logUserOut: function(){
    sap.m.URLHelper.redirect("logout.html", false);

Create a simple logout page

  <body class="sapUiBody" role="application">
  You have been logged out!

Modify the neo-app.json to define the logoutPage property. Access to the logout.html does not require the user to be logged in.

"welcomeFile": "index.html",
  "logoutPage": "/logout.html",
  "routes": [

NOTE: When testing this it will only log you out of the application when it is deployed to HCP and in the active state.  When testing within Web IDE it will just perform the redirect without logging you out. 


Jamie Cawley

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

    1. Jamie Cawley Post author

      Hi Wolfgang,

      I updated the blog to reflect the change.  The userapi logout still works, but this seems to be a better approach.



      SAP – Technology RIG

      1. Sascha Scholz


        with the old approach, the user is only logged out of the current application without ending the session on the IdP (Identity Provider, e.g. SAP ID Service). By reloading the application the application you would therefore be automatically logged in again.

        Unfortunately, the announcement in the release notes for the logout page didn’t mention that the old API had been deprecated.


    1. Jamie Cawley Post author

      Hi Ishita,

      Please create a new thread in the questions and answers section providing as much detail as possible explaining your issue.



    1. Jamie Cawley Post author

      Please create a new post in the questions and answers area and provide all of the related detail including screenshots of the configuration.




Leave a Reply