title: IdentityServer Authentication Endpoint -> error=invalid_request failureReason="STATUS_CODE"
body: <p>I am currently implementing SSO for one third-side service. The service doesn't support OIDC or OAuth, so I need to implement it proprietary. What I have is middleware, which handles requests. When it reckognizes request as login request from third side app, it creates authorize link and redirects it to [identityserver]/connect/authorize, which is authorize endpoint. Then server should give me back jwt token, which I would process. Anyway identity server gives me error and when I look into log file I can see <code>failureReason="STATUS_CODE"</code>. But <code>Response.Redirect()</code> sets <strong>status code 302</strong>, which should be just fine, shouldn't be?</p>
  
  <p>Client is set up just fine. I am using Implicit flow. However for AuthorizationCode or ClientCredentials sends me to error page with message: The client application is not known or is not authorized. Status code 204. </p>
  
  <p>Middleware snippet:</p>
  
  <pre><code>            string url = $"{context.Request.Scheme}://{context.Request.Host}";
              DiscoveryClient discoveryClient = new DiscoveryClient("https://localhost:44300/");
              DiscoveryResponse doc = await discoveryClient.GetAsync();
  
              AuthorizeRequest authorizeRequest = new AuthorizeRequest(doc.AuthorizeEndpoint);
              string authorizeUrl = authorizeRequest.CreateAuthorizeUrl(
                  clientId: "zendesk",
                  responseType: "id_token token",
                  scope: "openid email profile",
                  redirectUri: $"{url}/zendesk/authenticated",
                  state: Base64Url.Encode(returnTo.ToBytes()));
  
              context.Response.Redirect(authorizeUrl);
  
              return;
  </code></pre>
  
  <p>Redirected link:</p>
  
  <p><a href="https://localhost:44300/connect/authorize?client_id=zendesk&amp;response_type=id_token+token&amp;scope=openid+email+profile&amp;redirect_uri=https%3A%2F%2Flocalhost%3A44327%2Fzendesk%2Fauthenticated&amp;state=[64encodedValue]" rel="nofollow noreferrer">https://localhost:44300/connect/authorize?client_id=zendesk&amp;response_type=id_token+token&amp;scope=openid+email+profile&amp;redirect_uri=https%3A%2F%2Flocalhost%3A44327%2Fzendesk%2Fauthenticated&amp;state=[64encodedValue]</a></p>
  
  <p>Result link:</p>
  
  <p><a href="https://localhost:44327/zendesk/authenticated#error=invalid_request&amp;state=[64encodedValue]" rel="nofollow noreferrer">https://localhost:44327/zendesk/authenticated#error=invalid_request&amp;state=[64encodedValue]</a></p>
  
  <p>Thanks for any hint, I am in dead end here.</p>