【问题标题】:B2C: Localization for messages originating from REST APIB2C:源自 REST API 的消息的本地化
【发布时间】:2020-01-21 12:46:18
【问题描述】:

我目前正在实现this example,以便在用户注册期间使用休息 API。

基本思路是API抛出409 Conflict错误来中断注册。

// Can I return a special "StringId" or something here for localization?
return new ConflictObjectResult(new B2CResponseModel($"A verification email sent to you. Please open your mail box and click on the link. If you didn't receive the email, please click on the 'Send verification email' button.", HttpStatusCode.Conflict));

我想向用户显示一条本地化为他们当前语言的消息。我更愿意在自定义策略中进行本地化,但我也接受 API 中的解决方案(需要为此获取用户语言)。

有没有办法进行这种本地化?比如通过 API 返回 StringId 并在策略中使用它?

我也在考虑不从 API 返回错误,而是显示message in a new screen(如How to display error returned from custom REST API endpoint in a subsequent orchestration step?)。但是,我也无法找到这方面的本地化选项。

【问题讨论】:

    标签: azure azure-ad-b2c identity-experience-framework


    【解决方案1】:

    希望这类似于this

    查看 Jas Suri 的答案。将本地化参数传递给 API 并返回本地化消息,或者可以返回错误代码并基于使用策略本身显示的翻译消息。

    【讨论】:

      【解决方案2】:

      如果有人正在寻找将用户的语言环境发送到 REST API 的方法:

      https://docs.microsoft.com/nb-no/azure/active-directory-b2c/claim-resolver-overview

              <TechnicalProfile Id="REST-API-SendVerificationEmail">
                <DisplayName>Sign-Up send link</DisplayName>
                <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
                <Metadata>
                  <Item Key="ServiceUrl">https://xxxx</Item>
                  <Item Key="AuthenticationType">None</Item>
                  <Item Key="SendClaimsIn">Body</Item>
                </Metadata>
                <InputClaims>
                  <InputClaim ClaimTypeReferenceId="email" />
                  <InputClaim ClaimTypeReferenceId="userLanguage" DefaultValue="{Culture:LanguageName}" />
                  <InputClaim ClaimTypeReferenceId="policyId" PartnerClaimType="policy" DefaultValue="{Policy:PolicyId}" />
                  <InputClaim ClaimTypeReferenceId="scope" DefaultValue="{OIDC:scope}" />
                  <InputClaim ClaimTypeReferenceId="clientId" DefaultValue="{OIDC:ClientId}" />
                </InputClaims>
                <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
              </TechnicalProfile>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-01
        • 1970-01-01
        • 2019-03-26
        • 1970-01-01
        相关资源
        最近更新 更多