Azure AD B2C Custom Policy Localized Claim in REST Technical Profile

Adrian Martinez 0 Reputation points
2023-05-03T23:51:34.18+00:00

Hi, I need to pass an input claim with a localized DefaultValue within a RESTful provider technical profile (not within a Self-Asserted technical profile) of a custom policy but as soon as I add the reference to the transformation method GetLocalizedStringsTransformation within InputClaimsTransformations my application crashes (ADB2C: An exception has occurred).

The localized input claim must be within the RESTful provider technical profile.

Custom Claim definition:

<ClaimsSchema>
    <ClaimType Id="localizedResult">
        <DataType>string</DataType>
        <UserInputType>Readonly</UserInputType>
    </ClaimType>
</ClaimsSchema>

Localization:

<Localization Enabled="true">
    <SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
      <SupportedLanguage>en</SupportedLanguage>
      <SupportedLanguage>es</SupportedLanguage>
    </SupportedLanguages>
    <LocalizedResources Id="api.selfasserted.en">
      <LocalizedStrings>
        <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="localized_string">English Value</LocalizedString>
      </LocalizedStrings>
    </LocalizedResources>
    <LocalizedResources Id="api.selfasserted.es">
      <LocalizedStrings>
        <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="localized_string">Valor en Espanol</LocalizedString>
      </LocalizedStrings>
    </LocalizedResources>
</Localization>

Claim Transformation:

<ClaimsTransformations>
    <ClaimsTransformation Id="GetLocalizedStringsForCustomClaim" TransformationMethod="GetLocalizedStringsTransformation">
        <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="localizedResult" TransformationClaimType="localized_string" />
        </OutputClaims>
    </ClaimsTransformation>
</ClaimsTransformations>

RESTful provider technical profile:

<TechnicalProfile Id="REST-Technical-Profile">
    <DisplayName>My App</DisplayName>
    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
    <Metadata>
        <Item Key="IncludeClaimResolvingInClaimsHandling">true</Item>
        <Item Key="ContentDefinitionReferenceId">api.selfasserted</Item>
        <Item Key="ServiceUrl">https://my-app.test/api/endpoint</Item>
        <Item Key="SendClaimsIn">Body</Item>
        <Item Key="AuthenticationType">Bearer</Item>
    </Metadata>
    <InputClaimsTransformations>
        <InputClaimsTransformation ReferenceId="GetLocalizedStringsForCustomClaim" />
    </InputClaimsTransformations>
    <InputClaims>
        <InputClaim ClaimTypeReferenceId="myCustomClaim" DefaultValue="{Claim:localizedResult}" AlwaysUseDefaultValue="true" />
    </InputClaims>
</TechnicalProfile>

I tried with the method CreateStringClaim and it created a transformed value as expected but that method doesn't allow me to map translations based on language and custom translation collection.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Akshay-MSFT 17,956 Reputation points Microsoft Employee Moderator
    2023-05-18T10:54:47.3733333+00:00

    @Adrian Martinez

    Thanks for your time and patience, if we go by you REST-API technical profile:

    <Item Key="AuthenticationType">Bearer</Item>

    If the type of authentication is set to Bearer, the CryptographicKeys element contains the following attribute:

    User's image

    Could you please try to add the following and confirm :

    <CryptographicKeys>
        <Key Id="BearerAuthenticationToken" StorageReferenceId="B2C_1A_B2cRestClientAccessToken" />
      </CryptographicKeys>
    
    

    User's image

    Please do let me know the behavior.

    Thanks,

    Akshay Kaushik

    Please "Accept the answer" (Yes), and share your feedback if the suggestion answers you’re your query. This will help us and others in the community as well.


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.