I need to access custom attributes I’ve set during registration for my users, fetch and then modify them. Using the Get Current User API doesn’t return those information (why?). Furthermore i noticed under User Model APIs that you can actually return more fields but there no example on how to do that.
But users info can be accessed only if you are authenticated as Admin, so no use for everyone. Furthermore those APIs seems not working in localhost due to CORS header missing in the API’s response
How are you registering your users?
I believe what you want to do is get the custom claims into either A) the tokens or B) userInfo endpoint. You can access the appuser’s information in an expression to get appuser.customAttributeName and configure your authorization server’s claims to do exactly that.
Let me know any questions.
Through your beta registration service inside your hosted widget.
From your other answer here I learned that I have to pass through my backend to fetch users information but I’m struggling to understand how to get the users ID from the
By now, the only way i found to get user app infos is to retrive the id with the Java SDK using principal.name, then use the id to query the APIs, but it’s kinda long, there must be an easier way.
You can use SDK Methods to Fetch And Then modify custom attributes of IAppUser.
you can fetch User using following SDK Method:-
These are Asynchronous Methods. You can use following 2 methods to fetch:-
public async Task GetOktaApplicationUser(string oktaProfileId)
var x = await
var userApp = client.GetOktaApplicationUser(oktaProfileId).Result;
var userWithCustomAttributes = userApp.GetData(); //Getdata() to get Custom Attributes of User
//You can use jsonConvert to serialize it so that you can deserialize it to get data in your own //Model(class)
string json = JsonConvert.SerializeObject(userWithCustomAttributes, Formatting.Indented);
userWithCustomModel = JsonConvert.DeserializeObject<“CustomModel”>(json);
Above Method was to get User … Then you can modify and send the modified user using following SetProperty() Method of IAppUser as follows:-
public async Task UpdateApplicationUser(CustomModel user)
IAppUser appuser = new Okta.Sdk.AppUser();
appuser.Profile = new Resource();
appuser.Id = user.id;
appuser.Profile.SetProperty("<“Your custom attribute name”>", user.profile.Roles); //Or any
//attributes you’re having
var x = await Client.Applications.UpdateApplicationUserAsync(appuser, ConfigurationManager.AppSettings[“okta:ClientId”], appuser.Id);
UpdateApplicationUserAsync this method will modify your custom attributes which you set using setproperty()
In setproperty() first argument I’ve used string constant you can use your own according to your mapping variable name for that particular custom attribute.
return true; }