Azure AD b2c Custom Policies Customising Error Message.

Hetul Patel 1 Reputation point
2022-10-06T05:24:07.69+00:00

Hello,

I have implemented the b2c customized policies and I am currently defining the default error messages. However, the login error message displays a default error message.

<LocalizedResources Id="api.signuporsignin.en">  
                <LocalizedStrings>  
  
                    <LocalizedString ElementType="ErrorMessage" StringId="DefaultUserMessageIfRequestFailed">User account could not be found in the database.</LocalizedString>  
  
                    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfCircuitOpen">Unable to connect to the restful service end point.</LocalizedString>  
  
                    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfDnsResolutionFailed">Failed to resolve the hostname of the restful service endpoint.</LocalizedString>  
  
                    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfRequestTimeout">Failed to establish connection to restful service end point within timeout limit.</LocalizedString>  
  
                </LocalizedStrings>  
  
            </LocalizedResources>  

Can I display a dynamic error message exception-wise instead of the default error message?
Note: exception-wise error message come from API response.

How can I achieve this functionality?

Thanks!!

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,678 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 28,106 Reputation points Microsoft Employee
    2022-10-06T11:38:00.28+00:00

    Hi @Hetul Patel ,

    Thanks for reaching out.

    To get the exception from Rest API, you need to call your REST API as a validation technical profile as part of a self asserted technical profile.

    The validation technical profile returns returns 4xx HTTP status code and can be presented to the screen, as there is a page being rendered.

       <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">  
          <ValidationTechnicalProfiles>  
            <ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingLogonEmail" />  
            **<ValidationTechnicalProfile ReferenceId="REST-API" />**  
          </ValidationTechnicalProfiles>  
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />  
        </TechnicalProfile>  
    

    Generally, when your API sends an error response to AAD B2C, it will halt the execution of the journey, but with validation technical profile you can handle this behavior using ContinueOnError.

    hope this will help.

    Thanks,
    Shweta

    ---------------------------------------

    Please remember to "Accept Answer" if answer helped you.