title: Authorize Policy attribute always returns 403 forbidden using .net core Identity and JwtBearerAuthentication
body: <p>Following <a href="https://auth0.com/blog/asp-dot-net-core-authentication-tutorial/" rel="noreferrer">this guide</a> I was able to get authentication working using </p>
  
  <pre><code>Microsoft.AspNetCore.Identity.EntityFrameworkCore
  Microsoft.AspNetCore.Authentication.JwtBearer
  </code></pre>
  
  <p>Now I'm trying to secure my api endpoints with either roles, or claims. I've tried both with the same result (403)</p>
  
  <p>Using just <code>[Authorize]</code> works fine.</p>
  
  <p>My code currently looks something like this:</p>
  
  <blockquote>
    <p>Controller:</p>
  </blockquote>
  
  <pre><code>[Authorize(Policy = "RequireUserRole")]
  // Also tried [Authorize(Roles="User")]
  public string Get()
  {   
    return "YO";
  }
  </code></pre>
  
  <blockquote>
    <p>Startup:</p>
  </blockquote>
  
  <pre><code>services.AddIdentity&lt;IdentityUser, IdentityRole&gt;().AddEntityFrameworkStores&lt;ApplicationContext&gt;();
  services.Configure&lt;JWTSettings&gt;(Configuration.GetSection("JWTSettings"));
  services.AddAuthorization(options =&gt;
  {
          options.AddPolicy("RequireUserRole", policy =&gt; policy.RequireRole("User"));
  });
  </code></pre>
  
  <p>...</p>
  
  <pre><code>app.UseIdentity();
  
  var secretKey = Configuration.GetSection("JWTSettings:SecretKey").Value;
  var issuer = Configuration.GetSection("JWTSettings:Issuer").Value;
  var audience = Configuration.GetSection("JWTSettings:Audience").Value;
  var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey));
  
  app.UseJwtBearerAuthentication(new JwtBearerOptions
  {
          AutomaticAuthenticate = true,
          AutomaticChallenge = true,
          TokenValidationParameters = new TokenValidationParameters
          {
                  ValidateIssuerSigningKey = true,
                  IssuerSigningKey = signingKey,
  
                  // Validate the JWT Issuer (iss) claim
                  ValidateIssuer = true,
                  ValidIssuer = issuer,
  
                  // Validate the JWT Audience (aud) claim
                  ValidateAudience = true,
                  ValidAudience = audience,
  
                  ValidateLifetime = true
          }
  });
  
  app.UseMvcWithDefaultRoute();
  </code></pre>
  
  <p>and when I create the user I assign it to the role "User"</p>
  
  <pre><code>await _userManager.AddToRoleAsync(user, "User");
  </code></pre>
  
  <p>The role relationship is being created successfully, but the validation for the role when hitting the endpoint is failing.</p>
  
  <p>Any help appreciated!</p>