title: Registering OAuth authorization service middleware
body: <p>How can i register the <code>OAuthAuthorizationServerMiddleware</code> and <code>OAuthBearerAuthenticationMiddleware</code> in ASP.NET 5?</p>
  
  <p>I tried the following:</p>
  
  <pre><code>app.UseMiddleware(typeof(OAuthAuthorizationServerMiddleware), OAuthServerOptions);
  app.UseMiddleware(typeof(OAuthBearerAuthenticationMiddleware), new OAuthBearerAuthenticationOptions());
  </code></pre>
  
  <p>But this throws the following error:</p>
  
  <pre><code>System.Exception: TODO: unable to locate suitable constructor for Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationMiddleware. Ensure 'instanceType' is concrete and all parameters are accepted by a constructor.
  </code></pre>
  
  <p>I'm trying to port token based authentication implemented in this (<a href="https://github.com/attilah/AngularJSAuthentication/blob/master/AngularJSAuthentication.API/Startup.cs" rel="nofollow">click here</a>) application into ASP.NET 5.</p>
  
  <p>I've hit a wall here, not being able to register the OAuth server middleware and OAuth Bearer authentication.</p>