自定义策略 RESTful-Api UserJourney 错误

Custom Policy RESTful-Api UserJourney Error

我正在开发一个 RESTful 服务,它在 Azure AD B2C 的 Signup/Signin 进程中被调用。我的服务日志状态,数据成功到达,并创建了输出声明 (customerId)。

但是我收到以下错误消息,并且没有创建用户:

AADB2C90161 A self-asserted send response has failed with reason (Internal Server Error).
Correlation ID 7eac5fd2-cd85-4535-b166-4cc8f0264d07

我已将自己定位于此示例:https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/tree/master/scenarios/aadb2c-ief-rest-api-netfw/

有没有人遇到过类似的问题并提示我的情况可能是什么问题?

在 TrustFrameworkExtension 中:

<ClaimsProvider>
  <DisplayName>KTM REST APIs</DisplayName>
  <TechnicalProfiles>
    <TechnicalProfile Id="REST-API-SignUp">
      <DisplayName>Generate and return customerID claim</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://<my.service.com>/api/Identity/Signup</Item>
        <Item Key="AuthenticationType">None</Item>
        <Item Key="SendClaimsIn">Body</Item>
      </Metadata>

      <InputClaims>          
        <InputClaim ClaimTypeReferenceId="email" PartnerClaimType="Email" />
        <InputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="FirstName" />
        <InputClaim ClaimTypeReferenceId="surname" PartnerClaimType="LastName" />
        <InputClaim ClaimTypeReferenceId="testClaim" PartnerClaimType="ObjectId" />           
      </InputClaims>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="customerId" PartnerClaimType="CustomerId" />
      </OutputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>

    <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="customerId" PartnerClaimType="CustomerId" />
      </OutputClaims>
      <ValidationTechnicalProfiles>
        <ValidationTechnicalProfile ReferenceId="REST-API-SignUp" />
      </ValidationTechnicalProfiles>
    </TechnicalProfile>
  </TechnicalProfiles>
</ClaimsProvider>

在这种情况下,您有 运行 次错误。声明类型 "customerId" 在策略中被定义为字符串,但看起来通过网络传输的值(其中 partnerClaimType 为 "CustomerId")是一个数字,因此系统无法映射它。看到这一行:

<OutputClaim ClaimTypeReferenceId="customerId" PartnerClaimType="CustomerId" />

这就是 Rest API 将 return 字符串与数字的方式(注意数字中没有引号):

{
   "name": "John",
   "age": 24
}

虽然可以改进此消息,但you should configure your policy to collect logs using Application Insights。这将使您能够更轻松地调试类似 运行 时间的问题。