با سلام و خسته نباشید خدمت استاد گرامی و ممنون بابت دوره خوبی که برگزار کرده اید
من یک مشکلی در هنگامی که به آدرس /user/index میرم برام پیش میاد و این خطارو در مرورگر میگیره که ایجا میزارم
هرکاری هم کردم و وچندین بار کد رو بررسی کردم اما بازهم درست نشد
An unhandled exception occurred while processing the request.
OpenIdConnectProtocolException: Message contains error: 'invalid_client', error_description: 'error_description is null', error_uri: 'error_uri is null'.
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.GetPushedAuthorizationRequestUri(HttpResponseMessage parResponseMessage)این هم کدهای فایل Program.cs
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = "oidc";
}).AddCookie().AddOpenIdConnect("oidc", options =>
{
options.Authority = "https://localhost:5001";
options.ClientId = "ToplearnProjectId";
options.ClientSecret = "qwerty123456789";
options.ResponseType = "code";
options.Scope.Add("openid");
options.Scope.Add("profile");
options.Scope.Add("ToplearnApiScope");
options.SaveTokens = true;
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapStaticAssets();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}")
.WithStaticAssets();
app.Run();این هم کدهای فایل Config.cs
using Duende.IdentityServer.Models;
namespace SSO
{
public static class Config
{
public static IEnumerable<IdentityResource> IdentityResources =>
new IdentityResource[]
{
new IdentityResources.OpenId(),
new IdentityResources.Profile()
};
public static IEnumerable<ApiScope> ApiScopes =>
new ApiScope[]
{
new ApiScope()
{
Name = "ToplearnApiScope",
DisplayName = "Toplearn Api Scope",
Description = "Toplearn Api Scope Descroption",
Enabled = true,
ShowInDiscoveryDocument = true,
}
};
public static IEnumerable<Client> Clients =>
new Client[]
{
new Client()
{
ClientName = "Toplearn Project",
ClientId = "ToplearnProjectId",
Description = "This is a Secret Method",
AllowedGrantTypes = GrantTypes.Code,
ClientSecrets = [new Secret("qwerty123456789".Sha256())],
Enabled = true,
EnableLocalLogin = true,
AllowedScopes = ["profile","openid","ToplearnApiScope"]
}
};
}
}