title: ASP.NET API returns Authorization has been denied for this request on localhost but works normally on Azure
body: <pre><code>[Authorize]
      public class ValuesController : ApiController
      {
          // GET api/values
          public IEnumerable&lt;string&gt; Get()
          {
              return new string[] { "Simple" , "Test"};
          }
  }
  </code></pre>
  
  <p>This is a simple "Web API 2" app.</p>
  
  <pre><code>public void ConfigureAuth(IAppBuilder app)
          {
              app.UseWindowsAzureActiveDirectoryBearerAuthentication(
                new WindowsAzureActiveDirectoryBearerAuthenticationOptions
                {
                    Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
                    TokenValidationParameters = new TokenValidationParameters
                    {
                        SaveSigninToken = true,
                        ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
                    },
                });
          }
  </code></pre>
  
  <p>As shown the application is using the WindowsAzureActive Directory authentication and Authorization.</p>
  
  <p>Note that it works normally when published to Azure Api App, but always denies the request when in localhost.</p>
  
  <p>I am not sure what happened, it used to work before.</p>
  
  <p>Regards</p>