Why is preferred_username missing from ID token in Entra ID (Azure AD), even after adding it as an optional claim?

Johannes T 20 Reputation points
2025-03-19T16:27:19.6033333+00:00

Hi all,

We’re using Microsoft Entra ID (formerly Azure AD) for authentication via oidc 2.0 in a web application, and encountering an issue with missing token claims.

Specifically, the preferred_username claim is not present in the ID token, even though:

• The app is registered in Entra ID with openid profile email scopes.

• preferred_username has been explicitly added as an optional claim for the ID token under “Token Configuration” in the Azure Portal.

• We are using standard users from our tenant (not B2C).

• The token is being correctly issued (we receive upn, unique_name, and others — just not preferred_username).

• The issue persists even after forcing a new login session.

This is causing issues in our Spring Security backend, which expects preferred_username to be present by default when mapping user identity.

Has anyone encountered this before, or is there a documented reason why preferred_username may be omitted from the ID token in certain conditions? Are there workarounds besides manually mapping upn to preferred_username?

Thanks in advance for any insights!

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,242 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kancharla Saiteja 3,250 Reputation points Microsoft External Staff
    2025-03-24T09:36:22.41+00:00

    Hi @Johannes T,

    Based on your query, here is my understanding: you have added preferred_username as an optional claim which has not passed in token.

    Preferred_username claim is mutable which cannot be used for any authorization decisions and is only available for the users when you use v2.0 token. This claim is availble for the application when you have scope as profile for your application.

    In order to receive the token with preferred_username you may need to use this endpoint:

    • Well-known configuration document path: /.well-known/openid-configuration
    • Authority URL: https://login.microsoftonline.com/{tenant}/v2.0
    • v2.0: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

    The profile scope: The profile scope can be used with the openid scope and any other scope. It gives the app access to a large amount of information about the user. The information it can access includes, but not limited to, the user's given name, surname, preferred username, and object ID.

    Additional information:

    ID tokens in the Microsoft identity platform

    Scopes and permissions in the Microsoft identity platform

    v1.0 and v2.0 optional claims set

    I hope this information is helpful. Please feel free to reach out if you have any further questions.

    If the answer is helpful, please click "Accept Answer" and kindly "upvote it". If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.