I have been working with Auth0 on my Web API and ASP .NET MVC. Recently I decided to upload my Web API and MVC application to Azure. However, The Web API keeps replying “Authorization has been denied for this request” but it works fine when it runs in visual studio. Tested with postman and fiddler.
UPDATE:
I am using asp.net web api (owin), this is my configuration in the startup.cs:
public void Configuration(IAppBuilder app)
{
var domain = $"https://{ConfigurationManager.AppSettings"Auth0Domain"]}/";
var apiIdentifier = ConfigurationManager.AppSettings"Auth0ApiIdentifier"];
var keyResolver = new OpenIdConnectSigningKeyResolver(domain);
app.UseJwtBearerAuthentication(
new JwtBearerAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
TokenValidationParameters = new TokenValidationParameters()
{
ValidAudience = apiIdentifier,
ValidIssuer = domain,
IssuerSigningKeyResolver = (token, securityToken, identifier, parameters) => keyResolver.GetSigningKey(identifier)
}
});
// Configure Web API
WebApiConfig.Configure(app);
}