I ran into this same issue when I was configuring my Okta tenant (also integrated with Azure Active Directory).
Here's what worked for me:
var oktaDomain = _configuration["Okta:Domain"]?.ToString();
var oktaPrivateKey = _configuration["Okta:ApiKey"].ToString();
if (string.IsNullOrEmpty(oktaDomain) || string.IsNullOrEmpty(oktaPrivateKey))
throw new NullReferenceException("oktaDomain or oktaKey must be present");
var client = new OktaClient(new OktaClientConfiguration
{
OktaDomain = oktaDomain,
Token = oktaPrivateKey
});
var currentUser = await client.Users.GetUserAsync(userId);
if (currentUser != null)
{
currentUser.Profile["custom_attribute"] = myCustomAttribute;
await currentUser.UpdateAsync();
}
I should also note, that this will not be the end of your difficulties with updating custom profile attributes. If the claim mappings aren't configured correctly, you'll find that your profile attribute will initially be updated.
However, when a user signs back in, the value will revert back to what was mapped from Azure AD (usually blank).
To ensure the value actually persisted, you'll need to head to your Okta Profile Editor, for your Azure Active Directory profile, choose to edit the mappings. Then, make sure that your custom attributes are mapped as follows:
- Azure Active Directory To Okta User: appuser.custom_attribute > custom_attribute
- Okta User To Azure Active Directory: user.custom_attribute > custom_attribute
For Example:

I hope this helps, it was challenging to sort this out when I ran into it.