title: MVC 5 application - implement OAuth Authorization code flow
body: <p>Based on this tutorial <a href="http://www.asp.net/aspnet/overview/owin-and-katana/owin-oauth-20-authorization-server">http://www.asp.net/aspnet/overview/owin-and-katana/owin-oauth-20-authorization-server</a>, I have created an Authorization Server, a Resource Server and a MVC Client.
  The MVC Client has a Controller which gets some data from the Resource Server. The Resource Server requires authentication. The MVC Clients gets an authorization code from the Authorization Server and Redirects the user to the Authorization Server for authentication. Finally the MVC Clients exchanges the authorization code for a Access token to Access the Resource Server. This is the Authorization code flow as described by the OAuth 2 protocol. This works fine.</p>
  
  <p>Now, I have the requirement to make a Controller of the MVC Client itself require Authentication. I can not find a tutorial for this.</p>
  
  <p>I added</p>
  
  <pre><code>app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
  </code></pre>
  
  <p>to my Startup.Auth.cs.
  I assume, I need to setup the Options to Redirect to the Authorization Server. I can also set the Provider on the Options:</p>
  
  <pre><code>app.UseOAuthBearerAuthentication(new Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationOptions()
  {
      Provider = new OAuthBearerAuthenticationProvider()
  });
  </code></pre>
  
  <p>But I am also stuck on implementing the events of the Provider.
  Can anybody guide me in the right direction? Or are there any tutorials which might help me?</p>