MapBlazorHub with OIDC authorization 'Object reference not set to an instance of an object'

Viewed 63

I have a problem with oidc authorization. Authorization works but throws me 2 exceptions related to SignalR. I have no idea what to do with it. Neither the stack trace nor the exception message tells me anything.

First Exception:

Object reference not set to an instance of an object.

Stack Trace:

at Microsoft.AspNetCore.SignalR.ClientProxyExtensions.SendAsync(IClientProxy clientProxy, String method, Object arg1, Object arg2, Object arg3, CancellationToken cancellationToken)

Second Exception:

Object reference not set to an instance of an object.

Stack trace:

at Microsoft.AspNetCore.SignalR.ClientProxyExtensions.SendAsync(IClientProxy clientProxy, String method, Object arg1, Object arg2, Object arg3, CancellationToken cancellationToken) at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.EndInvokeDotNet(DotNetInvocationInfo invocationInfo, DotNetInvocationResult& invocationResult) at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.EndInvokeDotNetAfterTask(Task task, JSRuntime jsRuntime, DotNetInvocationInfo& invocationInfo) at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.<>c__DisplayClass5_0.b__0(Task t) at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Exceptions pop up when redirected to oidc authorization.

OIDC Configuration:

  .AddOpenIdConnect("oidc", options =>
            {
                options.Authority = configuration.GetSection("Authentication")["oidc:Authority"];
                options.ClientId = configuration.GetSection("Authentication")["oidc:ClientId"];
                options.ClientSecret = configuration.GetSection("Authentication")["oidc:ClientSecret"];
                options.RequireHttpsMetadata = false;
                options.GetClaimsFromUserInfoEndpoint = true;
                options.SaveTokens = true;
                options.RemoteSignOutPath = "/SignOut";
                options.SignedOutRedirectUri = "/login-callback";
                options.ResponseType = "code";
                options.BackchannelHttpHandler = new HttpClientHandler
                {
                    UseProxy = false,
                    UseDefaultCredentials = true
                };
            })

Calling oidc authorization:

 public async Task OnGet()
    {
        await HttpContext.ChallengeAsync("oidc", new AuthenticationProperties { RedirectUri = "/login-callback" });
    }
0 Answers
Related