JwtBearerAppBuilderExtensions.UseJwtBearerAuthentication(IApplicationBuilder
【JwtBearerAppBuilderExtensions.UseJwtBearerAuthentication(IApplicationBuilder】学向勤中得,萤窗万卷书。这篇文章主要讲述JwtBearerAppBuilderExtensions.UseJwtBearerAuthentication(IApplicationBuilder相关的知识,希望能为你提供帮助。
netcore从1.1升级到2.0时,出的错,因为使用的时Jwt token
参考https://github.com/aspnet/Security/issues/1310#issuecomment-314842779地址下的,
chris31389解答PinpointTownes 提问的问题,如下:
public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(options => { options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => { options.Authority = "http://localhost:30940/"; options.Audience = "resource-server"; options.RequireHttpsMetadata = https://www.songbingjia.com/android/false; }); }public void Configure(IApplicationBuilder app) { app.UseAuthentication(); // ... } }
所以我的解决方案如下:将原本写在Configure中的函数拿到ConfigureServices下进行配置。
services.AddAuthentication(options => { options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { IssuerSigningKey = TokenAuthOption.Key, ValidAudience = TokenAuthOption.Audience, ValidIssuer = TokenAuthOption.Issuer, ValidateIssuerSigningKey = true, ValidateLifetime = true, ClockSkew = TimeSpan.FromMinutes(0), }; });
推荐阅读
- Android应用Preference相关及源代码浅析(SharePreferences篇)
- scala中object和class的理解---apply方法是初始化方法
- 超赞!聊聊WEB APPHYBRID APP与NATIVE APP的设计差异
- MUI打包APP流程
- 准备Mahout所用的向量ApplesToVectors
- Web测试与APP测试有哪些异同()
- Android Studio使用JDBC远程连接mysql的注意事项(附示例)
- Android:设置EditText 背景
- Android和H5交互-基础篇