on 2021 Nov 28 2:44 PM
Dear Experts,
The app I am developing will be used both in Android and Web, where will need to identify current logged in User for processing in front end codes. My understanding we use UserID in #Application/#ClientData/UserId and it seems working correctly in Android, where it returns current users e-mail address. My problem is in Web application, where I get Empty value for this UserID. I read through some questions in the web but I couldn´t get clear answer if this is bug specifically for Web or something else.
So my 2 questions here:
1. Is it known issue/bug not being able to get UserId in Web version of MDK? If so what would be a workaround?
2. In Android as userID I get current logged users email (e.g. yyertuganov@example.com), is there way to get current logged users Login name instead (like SAP S or P ID or IAS Login id as e.g. 'S00254580' or 'YYERTUGANOV' ?
Many thanks,
Yergali
Request clarification before answering.
#Application/#ClientData/UserId in web runtime now returns the correct value. Please choose "Preview" web runtime option while deploying MDK metadata to Cloud Foundry.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"Production" web runtime will be updated in two weeks.
Thanks a lot Jitendra!!
Only one more thing, I see right now it returns current loged user, his/her email address, is there any way to access to other data like actual User ID, Name etc.
In case of Android we were accesing them thorugh GET to /mobileservices/application/${appId}/roleservice/application/${appId}/v2/Me..
yergaliyertuganov
I get the user ID from IAS in "id" property calling this request:
let appId = context.evaluateTargetPath('#Application/#ClientData/#Property:MobileServiceAppId');
let userInfoUrl = `/mobileservices/application/${appId}/roleservice/application/${appId}/v2/Me`;
let params = { 'method': 'GET' };
return context.sendRequest(userInfoUrl, params).then(r => {
if (r && r.statusCode === 200 && r.content) {
const userInfo = JSON.parse(r.content.toString());
appSettings.setString(`${appId}-UserId`,userInfo.id);
appSettings.setString(`${appId}-UserName`,userInfo.userName);
appSettings.setString(`${appId}-UserGivenName`,userInfo.name.givenName);
appSettings.setString(`${appId}-UserFamilyName`,userInfo.name.familyName);
appSettings.setString(`${appId}-UserEmail`,userInfo.emails[0].value);
appSettings.setString(`${appId}-UserFullName`,`${userInfo.name.givenName} ${userInfo.name.familyName}`);
return Promise.resolve();
}
},
(error) => {
console.log(error.toString());
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Francisco thanks a lot for your help!
I just have tried your code, it does work for Mobile/Android, however returns error (404 Not Found) in Web version. Couple of questions:
1. Do you use the same script for Web or only utilize for Android?
2. In Android it does return data, however in all 3 fields as id, userName and emails[0].value it gives me my e-mail address, but not actual values set in IAS for UserID and Login Name... First name and Last name are correct values from IAS. Maybe should I change something in IAS, where it seems like passing e-mail address for all 3 fields...
Many thanks,
Yergali
jitendrakumar.kansal Is there any advance about this known issue ?
My sap support ticket was closed automatically and solution attached was MDK 6.1.1.
I have tryed for web the same I do to get the user for mobile however still is not working:
let appId = context.evaluateTargetPath('#Application/#ClientData/#Property:MobileServiceAppId');
let userInfoUrl = `/mobileservices/application/${appId}/roleservice/application/${appId}/v2/Me`;
let params = { 'method': 'GET' };
return context.sendRequest(userInfoUrl, params).then(r => {
if (r && r.statusCode === 200 && r.content) {
const userInfo = JSON.parse(r.content.toString());
alert(userInfo.id + " " + userInfo.userName);
return Promise.resolve();
}
},
(error) => {
console.log(error.toString());
});
Thanks
Kiko
fjcarrasco
We are still investigating on this issue, we are hoping to provide you a solution soon.
1. This is a known problem, we will fix it.
2. The UserId value is coming from the identity provider set up in your BTP subaccount. Are you using the standard SAP IdP or your own IdP?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jitendra,
Thanks a lot for your response. Few comments:
1. Do you know more less when that fix for Web version will be out? This year or next?
2. We will be using SAP IAS service, where I have an account with my e-mail address, Login name and User Id. I have alreaded did onboarding with this account in Android and done some tests, where when I query #Application/#ClientData/UserId it always returns my e-mail address. Is there some settings I have to change or in IAS, BTP, Mobile Services o within my codes to get an User Id or Login name in IAS?
Thank you,
Yergali
User | Count |
---|---|
60 | |
10 | |
8 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.