'How to get B2C id_token inside ClaimsTransformation.cs

Is it possible to get the id_token returned by B2C after authentication inside of ClaimsTransformation.cs class?

I have tried to inject IHttpContextAccessor into the class, but it gets stuck in an infinite loop, calling the same method again and again, resulting in Stack Overflow error.



Solution 1:[1]

Try to add the following to the Azure AD OpenID Connect technical profile:

<ClaimsTransformations>
      <ClaimsTransformation Id="CreateOtherMailsFromEmail" TransformationMethod="AddItemToStringCollection">
        <InputClaims>
          <InputClaim ClaimTypeReferenceId="email" TransformationClaimType="item" />
          <InputClaim ClaimTypeReferenceId="otherMails" TransformationClaimType="collection" />
        </InputClaims>
        <OutputClaims>
          <OutputClaim ClaimTypeReferenceId="email" TransformationClaimType="collection" />
        </OutputClaims>
      </ClaimsTransformation>

Reference Link : https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/blob/main/LocalAccounts/TrustFrameworkBase.xml

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SureshBabu-MT