We have Identity Server 3 configured for our organization.
I am creating an application in .Net6 and want to connect and show the login page from Identity Server 3. But it seems like there are fair bit of challenges in it.
I am using the following code in .net6 application in Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("cookie", options =>
{
options.Cookie.Name = "mvcclient";
})
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "MyAuthorityUrlGoesHere";
options.RequireHttpsMetadata = false;
options.ClientId = "MyClientIdGoesHere";
options.Scope.Add("openid");
options.Scope.Add("profile");
options.ResponseType = "id_token"; //for implicit flow
});
The page redirects to the identity server but displays the error - "The client application is not known or is not authorized."
I think it is due to the fact that we need to set "RedirectUri" too in implicit flow, but somehow there is no property named RedirectUri any more :(
I couldnt find any links on google where they talk about connecting .net 6 application to identity server3. Although I was able to connect a .net4.5 application to identity server 3 and it shows a login page and then redirect me back to .net application.
Can someone please guide me through connecting .net 6 application to identity server 3.
Thanks
Ok I found the answer myself in another stack overflow thread:
In asp core there is a subpath silently appended
soo http://localhost:49946/signin-oidc had to be added to the redirect uris on identity server. And we dont need to give redirecturl at client