cancel
Showing results for 
Search instead for 
Did you mean: 

Get Logged in User Details in Freestyle SAP UI5 App

ramanareddy438
Explorer
0 Kudos

Hi,

I have created a Freestyle SAP UI5 application for a custom requirement. We will be using SAP IAS for SSO to the application. We would like to get the logged in user information in the app. I am trying with the following Approach. They are not working.

if (window.sap && window.sap.ushell && window.sap.ushell.Container && window.sap.ushell.Container.getUser()) {
	loggedInUser = window.sap.ushell.Container.getUser().getId().toUpperCase();
	console.log(loggedInUser);
}

if(sap & sap.ushell && sap.ushell.services && sap.ushell.services.UserInfo) {
	console.log(sap.ushell.services.UserInfo());
}

if(sap & sap.ushell && sap.ushell.Container) {
	console.log(sap.ushell.Container.getServiceAsync("UserInfo"));
}

None of the above code snippets are working. Please advise if there are any other options to get the logged in User details in the SAP Ui5 application. Let me know if any additional information is needed.

Best Regards

Ramana Reddy

gabmarian
Active Contributor

What kind of user data do you need?

Accepted Solutions (1)

Accepted Solutions (1)

gabmarian
Active Contributor
0 Kudos

You may use User API Service in Cloud Foundry. This blog gives an example how to use it thru SAP AppRouter.

ramanareddy438
Explorer
0 Kudos

Hi Marian,

Thank you for the response. Is there any example of this User API Service that I can refer in combination with UI5 app?

Answers (1)

Answers (1)

ramanareddy438
Explorer
0 Kudos

Hi @Marian,

I am looking primarily for Email Address of the logged in user.

Best Regards

Ramana Reddy

gabmarian
Active Contributor
0 Kudos

Please use the comment function unless you post a solution.

Is the application deployed to an on-premise SAP system?

ramanareddy438
Explorer
0 Kudos

I will comment going further. No, I deployed application to BTP CloudFoundry HTML5 applications.