How to Change the Username of an OIDC Application in Okta
Last Updated:
Overview
By default, Okta OIDC applications populate the preferred_username claim in the ID token with the user's primary email address (userName), which may not meet requirements when an application expects a custom username format. This issue is resolved by updating the application's attribute mappings in the Okta Profile Editor to map the desired profile attribute or custom Okta Expression Language value.
Applies To
- OpenID Connect (OIDC)
- Okta Identity Engine (OIE)
- Okta Classic Engine
- Profile Editor & Attribute Mapping
Solution
What requirements are needed for changing the Username of an OIDC Application?
- By default, the
preferred_usernameclaim is mapped as the "userName" in the application user profile, which will be populated as the primary email address of the user. - In order to receive the
preferred_usernameclaim in the user's ID token, the profile scope must be included in the /authorize request (specified in the app code/service provider's configuration dashboard).
How to modify the attributes from the Claim?
- Log in to the Okta Admin Console.
- Navigate to Directory > Profile Editor.
- Select Apps and locate the OIDC application.
- Click Mappings.
- In the profile mappings section, modify the following:
- Click Save Mappings and apply changes to existing users if prompted.
The preferred_username claim can be modified to return a different value from the user's profile. (even a custom expression value can be used)
Related References
- ID Token payload
- Authorization request
- Okta Expression Language Overview
- Customize Claims with Custom Authorization Servers
- OAuth 2.0 Scopes
