ASP.NET Core 2.0 JWT Validation fails with `Authorization failed for user: (null)` error

后端 未结 11 1455
暗喜
暗喜 2020-12-08 18:38

I\'m using ASP.NET Core 2.0 application (Web API) as a JWT issuer to generate a token consumable by a mobile app. Unfortunately, this token couldn\'t be validated by one con

11条回答
  •  旧巷少年郎
    2020-12-08 19:08

    For anyone using .NET Core 3.1, this is how it works:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
    
        app.UseCors("AllowOrigin");
        app.UseHttpsRedirection();
        app.UseRouting();
        app.UseAuthentication();
        app.UseAuthorization();
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }
    

提交回复
热议问题