I'm trying to add Azure MSAL Authentication to an existing Blazor WASM application that already handles authentication with JWT.
But if I register a custom AuthenticationStateProvider
I use, blazor throw at runtime:
Unhandled exception rendering component: Specified cast is not valid. System.InvalidCastException: Specified cast is not valid.
Looking through sources, It seems it throws because an MSAL class expects that IServiceProvider returns an IRemoteAuthenticationService<TRemoteAuthenticationState>
as AuthenticationStateProvider
see
Reference: .net core - Custom AuthenticationStateProvider
Authentication Failing - Stack Overflow