[Asp.Net Core 3.1] 取得JWT驗證後,Post API 錯誤訊息401 : the audience is invalid

public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;}).AddJwtBearer(options =>{options.TokenValidationParameters = new TokenValidationParameters{ValidateIssuer = false,ValidIssuer = jwtOptions[nameof(JwtOptions.Issuer)],ValidateAudience = false,ValidAudience = jwtOptions[nameof(JwtOptions.Audience)],ValidateIssuerSigningKey = true,IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(jwtOptions[nameof(JwtOptions.SecretKey)])),RequireExpirationTime = true,ValidateLifetime = true,ClockSkew = TimeSpan.Zero};});
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store