How do I configure App registration (for OIDC) to return "upn" and "roles" in the id-token and access-token?

Zambre, Akash 40 Reputation points
2025-05-07T11:58:25.5266667+00:00

I have a app registration created for OIDC. Have configured Optional claims under "Token configuration" to include "upn" in ID and Access tokens.
Yet I don't see this "upn" claim in id-token. I see it in access-token but not in id-token.

Also, is there a way to get AzureAD roles in these tokens as roles claim?


Update


Hi folks,

Follow-up on this, I added "profile" scope, updated "Token Configuration" to include "preferred_username" in both ID and Access tokens. Also, added group claim to include group info in the tokens as "role" claim. With this, I get "preferred_username" and "role" claims in ID token. However, Access token doesn't have these claims, am I missing something here?

FYI - We are using this access token for OAuth 2.0 REST api calls later on with same configuration.

Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
979 questions
{count} votes

Accepted answer
  1. Kancharla Saiteja 5,890 Reputation points Microsoft External Staff Moderator
    2025-05-08T13:01:14.23+00:00

    Hi @Zambre, Akash,

    Based on your query, here is my understanding: you would like to add optional claims to check the UPN in id token and would like to know how to get role claims.

    As per your description, you are not receiving UPN in ID token. UPN has different names based on the endpoint version you are using to retrieve the token. ID token can be retrieved using v1 or v2 version tokens. unique_name: Only present in v1.0 tokens. Provides a human readable value that identifies the subject of the token. This value isn't guaranteed to be unique within a tenant and should be used only for display purposes

    preferred_username: The primary username that represents the user. It could be an email address, phone number, or a generic username without a specified format. Its value is mutable and might change over time. Since it's mutable, this value can't be used to make authorization decisions. It can be used for username hints and in human-readable UI as a username. The profile scope is required to receive this claim. Present only in v2.0.

     Please take a look at the following document for more information: ID token claims reference

    If you would like to retrieve app roles to your application, please follow this document: Add app roles to your application and receive them in the token.These app roles we are talking here are assigned at app registrations but not the roles the user is assigned. While assigning a user to the application, it will provide you the options of roles created by you in App roles of the application only. In order to retrieve Microsoft Entra directory roles, you can configure the roles using the following document: Configure group claims and app roles in tokens.

    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.