title: OWIN Authorization Code flow always resturns "invalid_request" (400 Bad Request)
body: <p>I'm trying to add authorization code flow to my OWIN based application.</p>
  
  <p>My setup is:</p>
  
  <h1>Startup.cs</h1>
  
  <pre><code>// Enable JWT OAuth Authorization Server
  var opt = new OAuthAuthorizationServerOptions()
  {
      TokenEndpointPath = new PathString("/oauth/token"),
      AuthorizeEndpointPath = new PathString("/oauth/authorize"),
      AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(5),
      AuthorizationCodeExpireTimeSpan = TimeSpan.FromMinutes(5),
      Provider = new MyOAuthAuthorizationServerProvider(),
      RefreshTokenProvider = new MyRefreshTokenProvider(),
      AuthorizationCodeProvider = new MyAuthorizationCodeProvider(),
  #if DEBUG
      AllowInsecureHttp = true
  #endif
  };
  
  opt.AccessTokenFormat = new MyJwtFormat(opt);
  app.UseOAuthAuthorizationServer(opt);
  </code></pre>
  
  <h1>MyAuthorizationCodeProvider.cs</h1>
  
  <pre><code>public class MyAuthorizationCodeProvider : IAuthenticationTokenProvider
  {
      private readonly ConcurrentDictionary&lt;string, string&gt; _authenticationCodes = new ConcurrentDictionary&lt;string, string&gt;(StringComparer.Ordinal);
  
      public MyAuthorizationCodeProvider()
      {
      }
  
      public void Create(AuthenticationTokenCreateContext context)
      {
          context.SetToken(Guid.NewGuid().ToString("n") + Guid.NewGuid().ToString("n"));
          _authenticationCodes[context.Token] = context.SerializeTicket();
      }
  
      public Task CreateAsync(AuthenticationTokenCreateContext context)
      {
          Create(context);
          return Task.FromResult(0);
      }
  
      public void Receive(AuthenticationTokenReceiveContext context)
      {
          string value;
          _authenticationCodes.TryGetValue(context.Token, out value);
          context.DeserializeTicket(value);
      }
  
      public Task ReceiveAsync(AuthenticationTokenReceiveContext context)
      {
         Receive(context);
         return Task.FromResult(0);
      }
  }
  </code></pre>
  
  <p>While the password grant flow works, as well as it does the refresh token flow, the authorization code flow always returns an <code>"invalid_request"</code> when I request an HTTP GET to</p>
  
  <p><a href="http://host/oauth/authorize?response_type=code&amp;client_id=sample333&amp;redirect_uri=https%3A%2F%2Fhost%2F&amp;scope=access&amp;state=samplee666" rel="nofollow noreferrer">http://host/oauth/authorize?response_type=code&amp;client_id=sample333&amp;redirect_uri=https%3A%2F%2Fhost%2F&amp;scope=access&amp;state=samplee666</a></p>
  
  <p>I can't even debug my <code>MyAuthorizationCodeProvider</code> (no breakpoint hit in Create/Receive methods)</p>
  
  <p>I am surely missing something big :-) but I can't figure out what....</p>