dotnet / dotnet/aspnetcore

Blazor RemoteAuthenticatorView stuck in "Completing login..." after "No matching state found" error

Open
#49,221 12 comments 4 reactions 0 assignees View on GitHub
area-auth investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

Hello I have a Blazor WASM application that implements OIDC authentication using [authentication library](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/standalone-with-authentication-library?view=aspnetcore-7.0&tabs=visual-studio). I'm having a problem when users return back to the previous login URL by pressing the browser back button. This issue is described in more detail here: https://github.com/IdentityModel/oidc-client-js/issues/940. Doing some debugging I noticed that indeed I'm getting a "No matching state found in storage" error from Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js.

![No matching state](https://github.com/dotnet/aspnetcore/assets/34100964/b5109a62-280a-4763-911e-63ad652ca967)

This is expected behavior because the state is deleted from storage after successful login. What I would like to ask is a way to better handle this error. Right now it gets stuck Completing login... without showing any error to the user or the browser console. I would expect `RemoteAuthenticatorView` to switch to the `LogInFailed` RenderFragment and show the error that occurred.

What is the best way to handle this error?

### Expected Behavior

_No response_

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.