Logout does not work when using AddOidcAuthentication
See original GitHub issueWhen using AddOidcAuthentication in Blazor WebAssmbly standalone, the logout does not work. After logout the browser navigates to:
To Reproduce
Use same example described here. The error happens when BeginLogout is invoked.
@code{
private async Task BeginLogout(MouseEventArgs args)
{
await SignOutManager.SetSignOutState();
Navigation.NavigateTo("authentication/logout");
}
private void BeginLogin(MouseEventArgs args)
{
Navigation.NavigateTo("authentication/login");
}
}
Authentication registration
builder.Services.AddOidcAuthentication(options =>
{
builder.Configuration.Bind("Google", options.ProviderOptions);
});
App Settings
“Google”: { “Authority”: “https://accounts.google.com/”, “ClientId”: “****u.apps.googleusercontent.com”, “ClientSecret”: "“Not needed”, “PostLogoutRedirectUri”: “https://localhost:44316/authentication/logout-callback”, “RedirectUri”: “https://localhost:44316/authentication/login-callback”, “ResponseType”: “id_token” },
Error rendered in browser
There was an error trying to log you out: ‘’
Error shown in address bar
The%20logout%20was%20not%20initiated%20from%20within%20the%20page.
Further technical details
Project details
<PropertyGroup> <TargetFramework>net5.0</TargetFramework> <RuntimeIdentifier>browser-wasm</RuntimeIdentifier> <UseBlazorWebAssembly>true</UseBlazorWebAssembly> <RazorLangVersion>3.0</RazorLangVersion> </PropertyGroup>Referenced packages.
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.4" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<!--<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />-->
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="5.0.4" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="NSwag.ApiDescription.Client" Version="13.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Logout does not work when using AddOidcAuthentication ...
The logout works fine when I'm on the root page, however, if I'm on any other page it won't work and I get...
Read more >Login prompt after logout using Auth0 in ASP.NET Blazor ...
I managed to get it working but when I log out and go to log in again the app automatically authenticates without taking...
Read more >How do I add authentication to a Blazor WebAssembly app?
To support the authenticating service, add the AddOidcAuthentication service configuration to the Program.cs file. [Program.cs] using Microsoft.Extensions.
Read more >there's a bug where the logout link stops working if you ...
The issue is that when you click logout, you get a 400 error. This is due to the original LogOut page that came...
Read more >Blazor WASM auth
Currently trying to get Blazor WASM (Web Assembly) to work with Fusion Auth. My initial issue was to get to fusion auth at...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey Damir!
I tried to repro your observation. Please see my small sample here: https://github.com/ChristianWeyer/blazor-wasm-oidc-google-repro
I was not able to obey the same error you are seeing. (Please make sure the redirect URLs in your Google app are configured correctly). Could you take a look and let me know whether I missed a scenario in my code @ddobric ? Thanks!
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.