Search code examples
azure-ad-b2cazure-ad-b2c-custom-policymicrosoft-entra-id

B2C Sign-up screen shows {OIDC:LoginHint} instead of the login


I am passing an email of a prospective member in the login_hint from my website to B2C. In my custom policy I am setting the email claim of the "SignUp" TechnicalProfile to {OIDC:LoginHint}

<TechnicalProfile Id="CustomLocalAccountSignUpWithLogonEmail">
    <DisplayName>Email signup</DisplayName>
    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <Metadata>
        <Item Key="IpAddressClaimReferenceId">IpAddress</Item>
        <Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
    </Metadata>
    <CryptographicKeys>
        <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
    </CryptographicKeys>
    <InputClaims>
        <InputClaim ClaimTypeReferenceId="email" DefaultValue="{OIDC:LoginHint}" />
    </InputClaims>
    <OutputClaims>

But instead of seeing the user's email, the string {OIDC:LoginHint} is displayed in the form:

enter image description here

There is a similar question from 2018 with a suggested workaround of using JavaScript to populate the email field on the Sign Up form. But, I don't use custom templates, so the JavaScript workaround won't work for me.

All I need is to populate the email claim with the value passed in {OIDC:LoginHint}. Is there any way to solve this in the policy XML?


Solution

  • In a selfAsserted technical profile, you must:

    • The IncludeClaimResolvingInClaimsHandling metadata must be set to true.
    • The input or output claims attribute AlwaysUseDefaultValue must be set to true.

    https://learn.microsoft.com/en-us/azure/active-directory-b2c/claim-resolver-overview#using-claim-resolvers

    An example of using both settings is here https://learn.microsoft.com/en-us/azure/active-directory-b2c/claim-resolver-overview#restful-technical-profile