azure b2c - 发生异常

标签 azure exception oauth-2.0 azure-ad-b2c

我正在尝试使用 https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-ropc 在 Azure AD B2C 中设置资源所有者密码凭据流

我严格按照页面上的说明进行操作。当我尝试使用 Postman 登录时,收到错误“AADB2C:发生异常”。似乎无法查看错误的详细信息,并且标准 Azure 审核日志为空。

如何找到这些错误的详细信息?

我发现您可以配置应用程序洞察,但这需要自定义配置文件(这可能是我唯一的选择)

编辑 - 我让它工作了,结果发现我选择了错误的流量策略 - 所以如果你得到这个,请确保三重检查!我仍然认为这是一个错误或糟糕的用户体验,因为应该有一种方法可以自己实际调试错误,而无需联系 Microsoft。

最佳答案

阅读一些有关 Azure AD B2C 的精彩文档 here 。然后确保下载Gaining Expertise with Azure AD B2C .

检查此部分:使用 Application Insights 测试和调试自定义策略

我将把内容粘贴到这里以防万一:

You can use the detailed log information provided by Application Insights to investigate any issues that might occur with a custom policy. Use the following steps to configure IEF to send events directly to Application Insights.

  1. 使用 Visual Studio 打开 SignUpOrSignIn.xml 文件。
  2. 将以下属性添加到 <TrustFrameworkPolicy>元素。
    DeploymentMode="Development" UserJourneyRecorderEndpoint="urn:journeyrecorder:applicationinsights"
  • 根据<RelyingParty>元素,添加以下 <UserJourneyBehaviours>紧接着 <DefaultUserJourney ReferenceId="SignUpOrSignIn" /> 之后的节点元素。将粗体文本替换为您的应用程序 Insight Key。
  •     <UserJourneyBehaviors>
            <JourneyInsights TelemetryEngine="ApplicationInsights" InstrumentationKey="Your Application Insight Instrumentation Key" DeveloperMode="true" ClientEnabled="false" ServerEnabled="true" TelemetryVersion="1.0.0" />
        </UserJourneyBehaviors>
    

    注意以下几点:

    • DeveloperMode=true 有利于开发,但在大容量时受到限制,因为它告诉 Application Insights 通过处理管道加快遥测。
    • ClientEnabled="true"会将客户端脚本发送到 Application Insights,用于跟踪页面 View 和客户端错误
    • ServerEnabled="true"会将现有 UserJourneyRecorder JSON 作为自定义事件发送到 Application Insights

    ...

  • 保存文件。
  • 返回 Azure 门户并切换到 B2C 租户。打开 Azure AD B2C Blade 并选择身份体验框架。
  • 选择上传策略并上传 SignUpOrSignIn.xml 策略文件。选择覆盖该策略(如果存在)。
  • 检查 Application Insights 中的日志

    1. 选择 B2C_1A_signup_signin 政策。
    2. 选择立即运行。
    3. 尝试登录身份:
    • 无效用户(输入随机电子邮件地址)。 T
    • [email protected]但密码错误。
    • TestUser@AwesomeYourLastname.onmicrosoft.com 使用正确的密码。
  • 在 Azure 门户中,切换回 Azure 租户,然后打开 DemoInsightsForCustomPolicies Application Insights 资源。
  • 在“详细信息/概览”菜单中,选择“分析”。
  • 在 Application Insights Web 应用程序中打开一个新选项卡。
  • 使用以下任意示例查询来查看日志信息。
    • 跟踪:查看 Azure AD B2C 生成的所有日志
    • 痕迹|其中时间戳 > ago(1d):查看 Azure AD B2C 最后一天生成的所有日志
    • 痕迹| count:查看已生成了多少个事件
    • 痕迹|渲染饼图:将数据汇总为饼图

    请注意,您可能需要等待几分钟,日志才会开始显示在 Application Insights 中。

    如果需要进行详分割析,您可以下载查询结果并将其导出为CSV文件。

    您可以了解有关使用 Application Insights 执行分析的更多信息 here .

    ######

    按照这些步骤,我能够看到执行自定义密码重置策略时 B2C 返回的真实异常消息。见下文:

    enter image description here

    关于azure b2c - 发生异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54966167/

    相关文章:

    azure - 跳过 Azure AD Enterprise 应用程序中的主领域发现页面或 Microsoft 登录页面

    Azure DocumentDB 单一帐户需要为多个集合付费吗?

    ios - 0Auth2 : when do you use the refresh token to get a new access token? 过期前还是过期后?

    .net - AppDomain.UnhandledException 事件如何工作?

    oauth-2.0 - 使用 Google OAuth 2.0 刷新 token ,无需 client_secret

    rest - 如何使用服务帐户通过 OAuth2.0 向 Azure AD 进行身份验证

    azure - 如何使用 Azure DevOps 在 YAML 管道中输出替换 token ?

    azure - 奇怪的 DefaultAzureCredential 行为

    php - 如何处理 Doctrine 2 验证的异常

    c++ - 在信号处理程序中捕获 C++ 未处理的异常并恢复应用程序