Azure AD B2C MSAL acquireTokenSilent in React Library changes IdTokenClaims from LoginRedirect

Aditya Gour (NAV India) 40 Reputation points
2024-07-22T13:56:34.8066667+00:00

How can I keep the email claim in Access_Token the same as in IdTokenClaims when using acquireTokenSilent with MSAL react library for Azure AD B2C session management? The email claim is not coming in Access_Token after previously received IdTokenClaims were changed.

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,913 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Raja Pothuraju 7,750 Reputation points Microsoft Vendor
    2024-07-24T18:51:44.3533333+00:00

    Hello @Aditya Gour (NAV India),

    Thank you for posting your query on Microsoft Q&A.

    Based on your description, it seems you want to include the email claim in the access token for Azure AD B2C. If you are trying to achieve this for your User Flow, please follow these steps:

    1. In your Azure AD B2C tenant, select User flows.
    2. Select your policy (for example, "B2C_1_SignupSignin") to open it.
    3. Select Application claims and then select the email address attribute.
    4. Select Save.

    Once you've created a new user using the user flow, you can use the Run user flow feature on the user flow to verify the experience.

    If you are working with a custom policy, follow these steps:

    The Relying party policy technical profile output claims are values that are returned to an application. Adding output claims will issue the claims into the token after a successful user journey and will be sent to the application. Modify the technical profile element within the relying party section to add the desired claims as an output claim.

    1. Open your custom policy file. For example, SignUpOrSignin.xml.
    2. Find the OutputClaims element. Add the OutputClaim you want to be included in the token.
    3. Set the output claim attributes.

    Add below as extra output claims in rely-party policy to return email from signInNames.emailAddress for B2C users.

    <OutputClaim ClaimTypeReferenceId="email" />
    

    For further details, refer to the following documentation:

    Configure tokens in Azure AD B2C user flows: Configure tokens

    Azure AD B2C access tokens: Access tokens

    These resources should provide additional guidance on setting up and managing access tokens in Azure AD B2C.

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

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    Thanks,
    Raja Pothuraju.

    1 person found this answer 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.