有谁知道为什么我会收到"异常:关联失败"?

时间:2018-03-26 13:48:18

标签: c# .net asp.net-core

我需要帮助弄清楚为什么会发生这种异常。我在Chrome和Firefox中尝试过它。我认为我的配置有些错误,但我不知道在哪里。

这是我的" configureServices" Startup.cs中的方法:

  public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

        services.AddIdentity<ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores<ApplicationDbContext>()
            .AddDefaultTokenProviders();

        services.AddAuthentication(sharedOptions => { })
            .AddCookie()
            .AddOpenIdConnect("Twitch", "Twitch", openIdConnectOptions => {
                openIdConnectOptions.Authority = "https://id.twitch.tv";
                openIdConnectOptions.UseTokenLifetime = true;
                openIdConnectOptions.ClientId = "<removed>";
                openIdConnectOptions.ClientSecret = "<removed>";
                openIdConnectOptions.ResponseType = OpenIdConnectResponseType.IdToken;
                openIdConnectOptions.MetadataAddress = "https://api.twitch.tv/api/.well-known/openid-configuration";
                openIdConnectOptions.ProtocolValidator.RequireNonce = false;
                openIdConnectOptions.SaveTokens = true;
                openIdConnectOptions.GetClaimsFromUserInfoEndpoint = true;
                openIdConnectOptions.Scope.Add("openid");
                openIdConnectOptions.Scope.Add("user:read:email");
                openIdConnectOptions.Scope.Remove("profile");
                openIdConnectOptions.CallbackPath = "/signin-oidc";

            });

从我能够告诉Twitch的身份验证工作,当调用/ signin-oidc回调时似乎失败了。我收到以下例外:

  

例外:关联失败。   Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler&GT; + d__12.MoveNext()   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)   System.Runtime.CompilerServices.TaskAwaiter.GetResult()   Microsoft.AspNetCore.Authentication.AuthenticationMiddleware + d__6.MoveNext()   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)   Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware + d__4.MoveNext()   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)   Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware + d__6.MoveNext()   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware + d__6.MoveNext()   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotifica&gt; tion(任务任务)   Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware + d__7.MoveNext()

0 个答案:

没有答案