Skip to Content

Overview

The SAP Cloud Platform UserAPI provides a service which can be used to access details of the logged in user.  The details of this service can be found at

https://help.hana.ondemand.com/help/frameset.htm?1de599bf722446849d2b2e10132df42a.html

This service is available to html5 applications running on the Cloud Platform.  For an example of utilizing it in a html5 application see

Using the SAP HCP User API in SAP Web IDE

To utilize this service in a Mobile Services application we can perform the following

STEP 1: Create HTML5 App

To utilize this service in Mobile Services we first need to create an html5 app that exposes access to the service.  The only requirement for this app is to have a route defined in it’s neo-app.json for the userapi service.  You can either follow the above mentioned blog, add to any existing app running on the Cloud Platform or create a new UI5 app in Web IDE and add the following entry in the neo-app.json

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

After making the change deploy the app to the Cloud Platform.  This can be done in Web IDE by right clicking on the app and choosing Deploy -> Deploy to SAP Cloud Platform.  In my case I have provided the app name userapi.

STEP 2: Add connection in Mobile Services Development & Operations

In Mobile Service for Development and Operations choose the menu option Connections.  Add a new connection that points to your app with /services/userapi appended to the url as shown

Set the SSO Mechanism to Application To Application SSO

Add this connection to the desired application by choosing the tab Back End of the desired application and adding the connection to the Application Connections section

STEP 3: Finalize/Test Mobile Services Application

This scenario requires that you are using SAML authentication for the Mobile Services application.  This can be done by setting the Security Configuration property, found under the Information tab, of the app to Form.  For more information regarding the use of SAML with Kapsel application see

https://blogs.sap.com/2017/02/02/appendix-d-saml/

You should now be able to use this connection within your Kapsel app.  An example of accessing the CurrentUser would be as follows.

https://hcpms-XXXXXtrial.hanatrial.ondemand.com/userapi/currentUser

To report this post you need to login first.

3 Comments

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

  1. Shashank Paritala

    Hey Jamie,

    We have a unique workflow.  One where we use an edmx file from our real on-premise ODATA in WebIDE in order to build the application.  Once finished, we import the archive into our local machines and aim to change the application to the ODATA backend in Java EE.

    My question is how does one feed this WebIDE derived applications the serviceURL?  It seems there is no guide for this in specific.  I was hoping you could shed some light on it.

    As you know some clients just won’t allow cloud connector or WebIDE local Installation. Thank you.

    (0) 
    1. Jamie Cawley Post author

      Hi Shashank,

      Can you please create a new post in the Questions and Answers marked with the appropriates tags for you inquiry?

      Regards,

      Jamie

      (0) 

Leave a Reply