I have an IdentityServer and a MVC-Client, IdentityServer has its own web API's to provide user management to its clients.
MVC client uses HybridAndClientCredentials
grant type to interact with IdentityServer. I have no problem with authenticating client's user. The problem is when I try to call some API from IdentityServer with authenticated user, server returns login view instead of API's result.
Here is my client configuration:
new Client
{
ClientId = "mvc.identity.management",
ClientName = "Identity Management",
AllowedGrantTypes = GrantTypes.Hybrid,
RequireConsent = false,
ClientSecrets =
{
new Secret("somesecret".Sha256())
},
RedirectUris = { "http://localhost:5001/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:5001/signout-callback-oidc" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile
}
}
And client
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options =>
{
options.SignInScheme = "Cookies";
options.Authority = "http://localhost:5000";
options.RequireHttpsMetadata = false;
options.ClientSecret = "somesecret";
options.ResponseType = "code id_token";
options.GetClaimsFromUserInfoEndpoint = true;
options.ClientId = "mvc.identity.management";
options.SaveTokens = true;
});
Any advice will be helpful.