I have client app on target EntityFramework 4.8
config identity server is:
builder.Services.AddOpenIddict()
.AddCore(options =>
{
options.UseEntityFrameworkCore()
.UseDbContext<IdentityServerDbContext>();
})
.AddServer(options =>
{
options.SetAccessTokenLifetime(TimeSpan.FromDays(1));
options.SetTokenEndpointUris("connect/token")
.SetLogoutEndpointUris("connect/logout")
.SetAuthorizationEndpointUris("connect/authorize");
options.AllowAuthorizationCodeFlow();
options.AddEncryptionKey(new SymmetricSecurityKey(
Convert.FromBase64String("YYYYYYYYYY=")));
options.AddDevelopmentEncryptionCertificate()
.AddDevelopmentSigningCertificate();
options.UseAspNetCore()
.EnableAuthorizationEndpointPassthrough()
.EnableLogoutEndpointPassthrough()
.EnableTokenEndpointPassthrough();
options.AllowAuthorizationCodeFlow()
.AllowRefreshTokenFlow();
})
.AddValidation(options =>
{
options.UseLocalServer();
options.UseAspNetCore();
});
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(c =>
{
c.LoginPath = "/Authenticate";
});
and config client app .nbet core 7 is:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenIddict()
.AddValidation(options =>
{
options.SetIssuer("https://localhost:7000/");
options.AddAudiences("resource_server_1");
options.AddEncryptionKey(new SymmetricSecurityKey(
Convert.FromBase64String("YYYYYYYYYY=")));
options.UseSystemNetHttp();
options.UseAspNetCore();
});
and config client app .net framework 4.8 is
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
var tokenParameter = new TokenValidationParameters();
tokenParameter.IssuerSigningKey = new SymmetricSecurityKey(
Convert.FromBase64String("YYYYYYYYYY="));
var oidcOptions = new OpenIdConnectAuthenticationOptions
{
Authority = "https://localhost:7000",
ClientId = "milad-develop",
ClientSecret = "xx",
PostLogoutRedirectUri = "http://localhost:2020/account/logout",
RedirectUri = "http://localhost:2020/account/callback",
ResponseType = OpenIdConnectResponseType.Code,
Scope = "api1"
}
app.UseOpenIdConnectAuthentication(oidcOptions);
Now I have no problem with .net core programs, but my .net framework program always shows the token generated from the identity server as invalid and gives a 401 error.