How to customize Azure AD B2C custom policy configured error messages?

Gopi CK 31 Reputation points
2022-12-20T17:12:01.983+00:00

We have configured custom polices in Identity experience framework for the user sign in flows and other flows in Azure AD B2C to provide more customized experience to end users. Now we have to find how to customize azure errors/messages while user failed to enter correct information.

As per below image can see when user password expired and further while resetting to new password user enters wrong temporary password and correct new passwords. But Azure throw an error "invalid username or password" which is confuses to users rather it should say entered wrong temporary password.

can someone help with this how to customize these kind of erros?

272595-image.png

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Ali AlEnezi 1,081 Reputation points
    2022-12-20T17:16:38.5+00:00

    Hello,

    To customize the error messages displayed in an Azure Active Directory B2C (Azure AD B2C) custom policy, you will need to edit the policy files to include the desired error messages. The error messages displayed by Azure AD B2C are determined by the content of the policy files and can be customized by modifying the policy files to include the desired error messages.

    To customize the error messages in an Azure AD B2C custom policy, you can follow these steps:

    1. Navigate to the Azure AD B2C blade in the Azure portal.
    2. In the Identity Experience Framework section, click on the policy you want to customize.
    3. Click on the Edit button to open the policy in the policy editor.
    4. In the policy editor, navigate to the Localization tab.
    5. In the Localization tab, you can customize the error messages displayed by Azure AD B2C by modifying the content of the error message strings. For example, to customize the error message displayed when a user enters an incorrect temporary password during a password reset, you can modify the string for the "errorMessage.forgotPassword.tempPasswordIncorrect" error code.
    6. When you have finished customizing the error messages, click the Save button to save your changes.
    7. To deploy the updated policy, click the Publish button.

    Good luck!


  2. James Hamil 27,221 Reputation points Microsoft Employee Moderator
    2022-12-22T22:42:26.007+00:00

    Hi @Gopi CK , thank you for your question. I looked at your XML, and it looks correct. I found this Github issue. It's about language localization but I think we can apply Yoel's answer here.

    "The default error message configures a generic error message for unexpected errors. There are two errors that are related to the invalid username or password. One error for the username as blindfish3 mentioned above. The other one is for the password."

    ElementType="ErrorMessage" StringId="UserMessageIfInvalidPassword">Your password is incorrect.</LocalizedString>  
    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfInvalidPassword">We can't seem to find your account.</LocalizedString>  
    

    You may be overwriting the DefaultMessage with another LocalizedString. I would temporarily remove everything except for DefaultMessage and test to see if that updates properly. If not please let me know and I can help you further.

    If this answer helped you please mark it as "Verified" so other users can reference it.

    Thank you,
    James

    0 comments No comments

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.