Stack Exchange
Does anyone know why I'm receiving "Exception:correlation failed"?
I need help figuring out why this exception is happening. I've tried it in Chrome and Firefox. I figure my configuration is wrong some how but I don't see where.
Here is my "configureServices" method from 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";

            });

From what I am able to tell the authentication from Twitch is working, it seems to be failing when the /signin-oidc callback is called. I am receiving the following exception:

Exception: Correlation failed.
  Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler>+d__12.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  System.Runtime.CompilerServices.TaskAwaiter.GetResult()
  Microsoft.AspNetCore.Authentication.AuthenticationMiddleware+d__6.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware+d__4.MoveNext()
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  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>tion(Task task)
  Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware + d__7.MoveNext()


Pardon, I'll share a github resource. Hope is Ok. Check this thread: https://github.com/IdentityServer/IdentityServer4/issues/720

You can raise the Microsoft category logging to Debug level to get more info. The error probably comes from this line: https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs#L517

That said, double-check that the URL you are on before login, and after login are the same.

You can see what the correlation validation does here: https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs#L208-L243

Thanks for the suggestions. None of them worked for me so far. I've moved on to using the Twitch specific provider. Maybe later, I will go back to trying to get the OpenId provider to work when I have time.
