ASP.NET Www-Authenticate: Bearer error="invalid_token", error_description="The signature key was not found"

31 Views Asked by At

In my project, I share the same login with two different portals, and users of one portal cannot access the other. To solve this I created claims for user authorization, in my Startup.cs I have the following code snippet:

services.AddAuthorization(options =>
{
    options.AddPolicy(Policies.PortalDeComissoesPolicy, policy =>
    {
        policy.RequireClaim("PortalDeComissoes", "true");
    });
});

services.AddAuthentication(o =>
{
    o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
    o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
    options.RequireHttpsMetadata = false;
    options.SaveToken = true;
    options.TokenValidationParameters = new TokenValidationParameters
    {
        ValidateIssuerSigningKey = true,
        IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII
        .GetBytes(Configuration.GetSection("AppSettings:Token").Value)),
        ValidateIssuer = false,
        ValidateAudience = false
    };
});

And the problem is that, when publishing for approval in Azure, all requests are returning "401 Unauthorized", whereas locally on my machine the requests are normal.

I need requests published in the Azure environment to work

0

There are 0 best solutions below