authenticationjwtblazor-webassembly

Blazor Wasm: Microsoft.AspNetCore.Authentication.JwtBearer restored in server project but not in client project


There is an authentication package for blazor wasm Microsoft.AspNetCore.Authentication.JwtBearer that while downloading in blazor web assembly client project but isn't restored, In server project there is no problem.

I cleared nuget cache, deleted object and bin folders then rebuild. but in nuget manager, there is a cloud with a red icon next to this package in the client project.

Is there any restriction for blazor webassembly types, should not use this package? So how to resolve this issue?

EDIT:

As soon as I add Microsoft.AspNetCore.Authentication.JwtBearer all client project's packages show yellow exclamation marks. And when I remove Microsoft.AspNetCore.Authentication.JwtBearer package all other packages are successfuly restored.

This happens in Blazor webassembly client project and the server project has no problem with this package.

Can anyone help?


Solution

  • I found the problem, Under the Microsoft.AspNetCore.Authentication.JwtBearer in the package manager is written this is a middleware, So it can't be installed on the client project.

    I solved my problem by adding: System.IdentityModel.Tokens.Jwt package to client project. This is a sub package of Microsoft.AspNetCore.Authentication.JwtBearer that is available separately in nuget.