I tried to migrate my ASP CORE project to NET6 My project uses next packages
IdentityServer4.AccessTokenValidation - 3.0.1
IdentityModel.AspNetCore.OAuth2Introspection - 4.0.1
IdentityModel - 5.2.0
The build of project is success. But when I run application I get error
MissingMethodException: Method not found: 'IdentityModel.Client.DiscoveryEndpoint IdentityModel.Client.DiscoveryEndpoint.ParseUrl(System.String)'.
IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationOptions.ConfigureJwtBearer(JwtBearerOptions jwtOptions)
IdentityServer4.AccessTokenValidation.ConfigureInternalOptions.Configure(string name, JwtBearerOptions options)
Microsoft.Extensions.Options.OptionsFactory<TOptions>.Create(string name)
Microsoft.Extensions.Options.OptionsMonitor<TOptions>+<>c__DisplayClass10_0.<Get>b__0()
Anybody had this issue ?
Roman's answer is correct, we can fix it by doing the IdentityModel downgrade, but another way to fix that issue is by replacing the IdentityServer4.AccessTokenValidation by Microsoft.AspNetCore.Authentication.JwtBearer, and we can change a little bit the token validation, using IdentityServer4.AccessTokenValidation we were doing the validation like this:
services
.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(
options =>
{
options.Authority = configuration["Authentication:Authority"];
options.ApiName = configuration["Authentication:ApiName"];
});
Now we can do the token validation using the Microsoft.AspNetCore.Authentication.JwtBearer like that:
services
.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Authority = configuration["Authentication:Authority"];
options.RequireHttpsMetadata = false;
options.TokenValidationParameters.ValidAudiences = new List<string>() { configuration["Authentication:ApiName"] };
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With