Azure AD b2c Custom Policies Customising Error Message.

Hetul Patel 1 Reputation point


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">  
                    <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>  

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?


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

    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">  
            <ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingLogonEmail" />  
            **<ValidationTechnicalProfile ReferenceId="REST-API" />**  
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />  

    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.



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