Identity Server 3 - The client application is not known or is not authorized
<p>I am getting the error 'The client application is not known or is not authorized.' when accessing a protected area of my site.</p>

<p>Here's my Clients:</p>

<pre><code>public static class Clients
{
    public static IEnumerable&lt;Client&gt; Get()
    {
        return new[]
        {
            new Client
            {
                Enabled = true,
                ClientName = "Web Application",
                ClientId = "webapplication",
                Flow = Flows.AuthorizationCode,

                ClientSecrets = new List&lt;Secret&gt;
                {
                    new Secret("webappsecret".Sha256())
                },

                RedirectUris = new List&lt;string&gt;
                {
                    UrlManager.WebApplication
                },
                PostLogoutRedirectUris = new List&lt;string&gt;
                {
                    UrlManager.WebApplication
                },

                AllowedScopes = new List&lt;string&gt;
                {
                    Constants.StandardScopes.OpenId,
                    Constants.StandardScopes.Profile,
                    Constants.StandardScopes.Email,
                    Constants.StandardScopes.Roles,
                    Constants.StandardScopes.OfflineAccess,
                    "read",
                    "write"
                }
            }
        };
    }
}
</code></pre>

<p>Here's my web application startup:</p>

<pre><code>public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = "Cookies"
        });

        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        {
            Authority = UrlManager.AuthenticationService + "identity",

            ClientId = "webapplication",
            Scope = "openid profile",
            ResponseType = "code id_token",
            RedirectUri = UrlManager.WebApplication,

            SignInAsAuthenticationType = "Cookies"
        });
    }
}
</code></pre>

<p>This is my authentication service (where IDS3 is installed) startup:</p>

<pre><code>public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/identity", idsrvApp =&gt;
        {
            idsrvApp.UseIdentityServer(new IdentityServerOptions
            {
                SiteName = "Authentication Service - Embedded IdentityServer",
                SigningCertificate = Certificate.LoadCertificate(),

                Factory = new IdentityServerServiceFactory()
                            .UseInMemoryUsers(Users.Get())
                            .UseInMemoryClients(Clients.Get())
                            .UseInMemoryScopes(Scopes.Get())
            });
        });
    }
}
</code></pre>

<p>This is UrlManager:</p>

<pre><code>public static class UrlManager
{
    public static string WebApplication
    {
        get { return "https://localhost:44381/"; }
    }

    public static string AuthenticationService
    {
        get { return "https://localhost:44329/"; }
    }
}
</code></pre>

<p>This is my Home Controller:</p>

<pre><code>public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    [Authorize]
    public ActionResult Private()
    {
        return View((User as ClaimsPrincipal).Claims);
    }
}
</code></pre>

<p>When I access Private I get an Identity Server 3 screen that gives me the error message 'The client application is not known or is not authorized.'.</p>

<p>I have read that this can come from mis-matches in the redirect URIs but as far as I can see mine are correct. I don't know what else can cause it. The application works perfectly if I change the flow to implicit but I want to implement AuthorizationCode flow.</p>

<p>The documentation does not seem to shed any light on this either.</p>