Azure active directory OpenIdConnectAuthenticationNotifications.AuthorizationCodeReceived事件未触发

Azure active directory OpenIdConnectAuthenticationNotifications.AuthorizationCodeReceived事件未触发,azure-active-directory,Azure Active Directory,使用此示例: 当在本地运行时,它会按预期工作 但是当我们部署它(azure web app)时,它仍然进行身份验证,但OpenIdConnectAuthenticationNotifications.AuthorizationCodeReceived事件没有触发 这就是代码 app.UseOpenIdConnectAuthentication( new OpenIdConnectAuthenticationOptions { Cl

使用此示例:

当在本地运行时,它会按预期工作 但是当我们部署它(azure web app)时,它仍然进行身份验证,但OpenIdConnectAuthenticationNotifications.AuthorizationCodeReceived事件没有触发

这就是代码

    app.UseOpenIdConnectAuthentication(
        new OpenIdConnectAuthenticationOptions
        {
            ClientId = clientId,
            Authority = Authority,
            PostLogoutRedirectUri = redirectUri,
            RedirectUri = redirectUri,

            Notifications = new OpenIdConnectAuthenticationNotifications()
            {
                AuthorizationCodeReceived = OnAuthorizationCodeReceived,
                AuthenticationFailed = OnAuthenticationFailed
            }
        });


private async Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedNotification context)
{
    var code = context.Code;

    ClientCredential credential = new ClientCredential(clientId, appKey);
    string userObjectID = context.AuthenticationTicket.Identity.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
    AuthenticationContext authContext = new AuthenticationContext(Authority, new NaiveSessionCache(userObjectID));

    Uri uri = new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path));

    AuthenticationResult result = await authContext.AcquireTokenByAuthorizationCodeAsync(code, uri, credential, graphResourceId);
}
这是一个问题,因为它需要缓存令牌才能进行出站调用。 因为它没有它,它抛出

有一个问题导致了这与redir url后的尾随斜杠有关,但我们已经尝试过了

所以有两个问题… 1) 在什么情况下会触发事件?在本地运行时为什么会这样?根据文档,应“在安全令牌验证后,如果协议消息中存在授权码,则应调用该密码。”
2) 调试这个的最佳方法是什么?不清楚在这里找什么

1) 在什么情况下会触发事件?在本地运行时为什么会这样?根据文档,如果协议消息中存在授权码,则应“在安全令牌验证后调用”

作为文档点,当web应用验证协议消息中是否存在授权代码时,将触发此事件

2) 调试这个的最佳方法是什么?不清楚在这里找什么

当您使用access_令牌调用请求时,有许多原因可能会导致异常。例如,基于使用
NaiveSessionCache
的代码,它使用
Sesstion
对象持久化令牌。这意味着您在部署具有多个实例的web应用程序时也可能会遇到异常。为了解决这个问题,我建议您远程调试项目以找到根本原因。对于远程调试,您可以参考以下文档: