Search code examples
authenticationasp.net-coreidentityserver4

Identity Server 4 Consent Screen Never Shows


I'm trying to get the Consent Screen to show from the Identity Server 4 Samples, I've configured the client so it requires consent like so:

new Client
{
    ClientId = "openIdConnectClient",
    ClientName = "Example Implicit Client Application",
    AllowedGrantTypes = GrantTypes.Implicit,
    RequireConsent = true,
    AllowedScopes = new List<string>
    {
        IdentityServerConstants.StandardScopes.OpenId,
        IdentityServerConstants.StandardScopes.Profile,
        IdentityServerConstants.StandardScopes.Email,
        "role",
        "customAPI"
     },
     RedirectUris = new List<string> {"https://localhost:44330/signin-oidc"},
     PostLogoutRedirectUris = new List<string> { "https://localhost:44330" }
 }

The project contains controllers and views for the Consent Screen However I cannot get it to load. If needed I can show the classes or views for the Consent.

Does anyone know how to configure IdentityServer4 to Display the Consent Screen?


Solution

  • You can force the consent screen to always be shown in your client by setting the Prompt property when you register the OpenIDConnect scheme:

    .AddOpenIdConnect(options =>
            {
                options.Authority = "https://localhost:6001";
                options.ClientId = "xxx";
                options.ClientSecret = "xxxx";
                options.ResponseType = "code";
           
                ...
    
                options.Prompt = "consent";
            });