I have a requirement to get user claims of a user logged into API Manager. I would prefer to do this using jaggery.
However, when I try the following
var carbon = require('carbon');
var tenantId = -1234;
var url = 'https://10.100.0.49:9443/admin/services/';
var server = new carbon.server.Server(url);
var userManager = new carbon.user.UserManager(server, tenantId);
var user1 = new carbon.user.User(userManager, 'admin');
var userClaims = user1.getClaimsForSet(['http://wso2.org/claims/givenname'],'default');
print(userClaims);
I get {}
as the response. I have added a value for givenname for admin through the management console
I have also tried to get the claim value for another user who signed up to the API Store but to no avail.
Apart from this, I created a js module within carbon.user
, declared it in module.xml
and called it through a jag file. Once again, I get a response but it's empty ie. {}
. The service I linked through js was org.wso2.carbon.um.ws.service.UserStoreManagerService
I am actually using API Manager in conjunction with Identity Server. Both servers have been clustered according to the documentation given here https://docs.wso2.com/display/CLUSTER44x/Configuring+the+Identity+Server+5.2.0+as+a+Key+Manager+with+API+Manager+2.0.0 and here https://docs.wso2.com/display/CLUSTER44x/Configuring+the+Pre-Packaged+Identity+Server+5.2.0+with+API+Manager+2.0.0
Since the userstore is the same, I presume that even though the Identity Server is handling user management, I should be able to get the claims through API Manager.
However, just to be sure, I have also tried using API Manager as is and retrieving claims by the above method.
What could be the cause of this and how do I retrieve the claims I need?