title: Manually decode OAuth bearer token in c#
body: <p>In my Web Api 2.2 OWIN based application I have a situation where I manually need to decode the bearer token but I don't know how to do this.
  This is my startup.cs </p>
  
  <pre><code>public class Startup
  {
      public static OAuthAuthorizationServerOptions OAuthServerOptions { get; private set; }
      public static UnityContainer IoC;
      public void Configuration(IAppBuilder app)
      {
          //Set Auth configuration
          ConfigureOAuth(app);
  
          ....and other stuff
      }
  
      public void ConfigureOAuth(IAppBuilder app)
      {
          OAuthServerOptions = new OAuthAuthorizationServerOptions()
          {
              AllowInsecureHttp = true,
              TokenEndpointPath = new PathString("/token"),
              AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
              Provider = new AuthProvider(IoC.Resolve&lt;IUserService&gt;(), IoC.Resolve&lt;IAppSettings&gt;())
          };
  
          // Token Generation
          app.UseOAuthAuthorizationServer(OAuthServerOptions);
          app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
      }
  }
  </code></pre>
  
  <p>In my controller Im sending the bearer token as a parameter </p>
  
  <pre><code>[RoutePrefix("api/EP")]
  public class EPController : MasterController
  {
      [HttpGet]
      [AllowAnonymous]
      [Route("DC")]
      public async Task&lt;HttpResponseMessage&gt; GetDC(string token)
      {
          //Get the claim identity from the token here
          //Startup.OAuthServerOptions...
  
          //..and other stuff
      }
  }
  </code></pre>
  
  <p>How to manually decode and get the claims from the token passed as a parameter? </p>
  
  <p><strong>NOTE</strong>: I know I can send the token in the header and use [Authorize] and (ClaimsIdentity)User.Identity etc but the question is how to read the token when it's not presented in the header. </p>