Azure AD B2C中UserMessageIfWrongCodeEntered本地化失效问题求助
I’ve run into this exact headache before—turns out the UserMessageIfWrongCodeEntered string isn’t tied to the api.selfasserted.totp.[lang] localized resources like you’d expect, which is why your current setup isn’t working. Here’s how to fix it:
Correct Localization Resource Target
The TOTP verification error is emitted by the core TOTP validation component, not the self-asserted UI layer. You need to define the localized string under the api.totp.[lang] resource ID instead.
Add this block to your custom policy’s localization section:
<LocalizedResources Id="api.totp.sv"> <LocalizedStrings> <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfWrongCodeEntered">Koden är felaktig, försök igen.</LocalizedString> </LocalizedStrings> </LocalizedResources>
Additional Checks to Ensure It Works
- Verify RelyingParty Reference: Make sure your policy’s
RelyingPartysection enables localization and references theapi.totpresource. For example:<RelyingParty> <DefaultUserJourney ReferenceId="YourTOTPUserJourney" /> <Localization Enabled="true"> <SupportedLanguages DefaultLanguage="sv" MergeBehavior="ReplaceAll"> <SupportedLanguage>sv</SupportedLanguage> </SupportedLanguages> </Localization> </RelyingParty> - Clear Browser Cache: Azure AD B2C caches localization resources aggressively. Test your updated policy in incognito mode or clear your browser’s cache to avoid stale content.
- Validate XML Syntax: Double-check for typos or mismatched tags in your policy—even a small syntax error can break localization.
Why User Flow Changes Didn’t Work
If you’re using custom policies, any localization settings from user flows get overridden by your custom policy configuration. That’s why modifying the user flow entry had no effect on your custom policy’s behavior.
All other strings in api.selfasserted.totp.sv work because they’re tied to the UI elements of the TOTP setup/entry page, while the wrong-code error comes directly from the backend validation step.
内容的提问来源于stack exchange,提问作者Nait

