我有一个通过
Blazor Server app
进行身份验证的 ASP.NET Identity cookies
项目,并且我使用 APIs
方法向其中添加了几个 minimal API
。这些 API 旨在通过 mobile application
进行调用,并且 API 需要通过 JWT tokens
进行身份验证。我应该做什么才能实现这个目标?
当前身份验证配置:
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddScoped<IdentityUserAccessor>();
builder.Services.AddScoped<IdentityRedirectManager>();
builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>();
builder.Services
.AddAuthentication(options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ApplicationScheme;
}).AddIdentityCookies();
builder.Services.AddIdentityCore<User>(options => options.SignIn.RequireConfirmedAccount = false)
.AddRoles<Role>()
.AddEntityFrameworkStores<Infrastructure.Persistence.ApplicationDbContext>()
.AddSignInManager()
.AddDefaultTokenProviders();
观看此视频,其中使用了以下两者: https://m.youtube.com/watch?v=w5w00b6V6fw