title: Always getting the "Authorization has been denied for this request." message
body: <p>I'm able to successfully retrieve token, but when trying to authenticate using the token I always get the <code>Authorization has been denied for this request</code> message.</p>
  
  <p>My <code>Startup.cs</code> file contains the following methods</p>
  
  <pre><code>public void Configuration(IAppBuilder app)
  {
      var config = new HttpConfiguration();
      WebApiConfig.Register(config);
  
      app.UseWebApi(config);
  
      ConfigureOAuth(app);
  
      var jsonFormatter = config.Formatters.OfType&lt;JsonMediaTypeFormatter().First();
      jsonFormatter.SerializerSettings
                   .ContractResolver = new CamelCasePropertyNamesContractResolver();
  }
  
  private void ConfigureOAuth(IAppBuilder app)
  {
      var oAuthServerOptions = new OAuthAuthorizationServerOptions()
      {
          AllowInsecureHttp = true,
          TokenEndpointPath = new PathString("/Token"),
          AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
          Provider = new DefaultAuthorizationServerProvider()
      };
  
      app.UseOAuthAuthorizationServer(oAuthServerOptions);
      app.UseOAuthBearerAuthentication(new   OAuthBearerAuthenticationOptions());
  }
  </code></pre>
  
  <p>The <code>DefaultAuthorizationServerProvider.cs</code> class contains the following</p>
  
  <pre><code>public class DefaultAuthorizationServerProvider : OAuthAuthorizationServerProvider
  {
      public override async Task ValidateClientAuthentication
          (
          OAuthValidateClientAuthenticationContext context
          )
      {
          context.Validated();
      }
  
      public override async Task GrantResourceOwnerCredentials
          (
          OAuthGrantResourceOwnerCredentialsContext context
          )
      {
          context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
  
          var identityManager = new IdentityManager();
  
          var identity = identityManager.Get(context.UserName, context.Password,
              new IpAddressProvider().Provide(IpAddressType.Forwarding));
  
          if (identity == null)
          {
              context.SetError("invalid_grant", "Authentication failed. Please make sure you provided the correct username and password.");
          }
          else
          {
              identity.AddClaim(new Claim(ClaimTypes.Role, "User"));
              context.Validated(identity);
          }
      }
  }
  </code></pre>
  
  <p>And the <code>IdentityManager.cs</code> class have the following</p>
  
  <pre><code>public class IdentityManager : IIdentityManager
  {
      public virtual ClaimsIdentity Get
         (
         string username,
         string password,
         string ipAddress
         )
      {
          var authenticateUserWorkflowOutput = new AuthenticateUserWorkflowHelper().Execute
              (
                  new AuthenticateUserWorkflowInput
                  {
                      Username = username,
                      Password = password,
                      IpAddress = ipAddress
                  },
                  new AuthenticateUserWorkflowState()
              );
  
          if (authenticateUserWorkflowOutput.Message.Exception != null)
          {
              return null;
          }
  
          if (!authenticateUserWorkflowOutput.Authenticated)
          {
              return null;
          }
  
          return authenticateUserWorkflowOutput.User != null ? new Infrastructure.Identity(new[]
          {
              new Claim(ClaimTypes.Name, authenticateUserWorkflowOutput.MasterUser.EmailAddress), 
          }, "ApplicationCookie") : null;
      }
  }
  </code></pre>
  
  <p>Using Fiddler I can successfully retrieve a token</p>
  
  <p><img src="https://i.stack.imgur.com/GzJvL.png" alt="enter image description here"></p>
  
  <p>But when I try to authenticate using the token I get the following response</p>
  
  <p><img src="https://i.stack.imgur.com/4m6A6.png" alt="enter image description here"></p>