title: ASP.Net Core 3.0 JWT Bearer Token No SecurityTokenValidator available
body: <p>I am using a ASP.Net Core 3.0 API with EntityFramework Core as UserStorage.
  Startup.cs:</p>
  
  <pre class="lang-cs prettyprint-override"><code>        public void ConfigureServices(IServiceCollection services)
              {
               using Microsoft.AspNetCore.Authentication.JwtBearer;
               using Microsoft.AspNetCore.Builder;
               using Microsoft.AspNetCore.Hosting;
               using Microsoft.AspNetCore.Identity;
               using Microsoft.AspNetCore.SpaServices.AngularCli;
               using Microsoft.EntityFrameworkCore;
               using Microsoft.Extensions.Configuration;
               using Microsoft.Extensions.DependencyInjection;
               using Microsoft.Extensions.Hosting;
               using Microsoft.IdentityModel.Tokens;
               using System;
               using System.Collections.Generic;
               using System.Linq;
               using System.Text;
               using System.Threading.Tasks;
                  .
                  .
                  .
  
                  //Add Identity Provider with EntityFramework
                  services.AddIdentity&lt;User, IdentityRole&gt;()
                  .AddEntityFrameworkStores&lt;ApplicationDBContext&gt;()
                  .AddDefaultTokenProviders();
  
                  //Initialize EntityFramework
                  services.AddDbContext&lt;ApplicationDBContext&gt;(options =&gt; options.UseSqlite(Configuration.GetConnectionString("localDB")));
  
                  //Initialize JWT Authentication
                  services.AddAuthentication(options =&gt; {
                      options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                      options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                  }).AddJwtBearer(jwtBearerOptions =&gt;
                  {
                      jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters()
                      {
                          ValidateIssuer = true,
                          ValidateAudience = true,
                          ValidateLifetime = true,
                          ValidateIssuerSigningKey = true,
  
                          ValidIssuer = "http://localhost:44352",
                          ValidAudience = "http://localhost:44352",
                          IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetSection("Secrets")["jwt"]))
                      };
                  }
                  );
                  services.AddMvc(options =&gt; options.EnableEndpointRouting = false)
                      .AddNewtonsoftJson();
  
                  // In production, the Angular files will be served from this directory
                  services.AddSpaStaticFiles(configuration =&gt;
                  {
                      configuration.RootPath = "ClientApp/dist";
                  });
              }
  
              .
              .
              .
  
  
                  app.UseHttpsRedirection();
                  app.UseStaticFiles();
                  app.UseSpaStaticFiles();
  
                  //Enable Authentication
                  app.UseAuthentication();
                  app.UseAuthorization();
  
                  .
                  .
                  .
  
                  app.UseMvc(routes =&gt;
                  {
                      routes.MapRoute(
                          name: "default",
                          template: "{controller}/{action=Index}/{id?}");
                  });
  
  
      .
      .
      .
  </code></pre>
  
  <p>This is my code issuing a JWT token:</p>
  
  <pre class="lang-cs prettyprint-override"><code>
  public async Task&lt;IActionResult&gt; Login()
          {
              using (var reader = new StreamReader(Request.Body))
              {
                  var body = await reader.ReadToEndAsync();
                  var cred = JsonConvert.DeserializeObject&lt;Credentials&gt;(body);
                  var result = (await userService.LoginUser(cred.userName, cred.password));
                  if (result == 200)
                  {
  
                      var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration.GetSection("Secrets")["jwt"]));
                      var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256Signature);
  
                      var roles = await userService.GetRoleFromUsername(cred.userName);
                      var rolesString = JsonConvert.SerializeObject(roles);
  
                      var tokeOptions = new JwtSecurityToken(
                                  issuer: "http://localhost:44352",
                                  audience: "http://localhost:44352",
                                  claims: new List&lt;Claim&gt;(new List&lt;Claim&gt; {
                                          new Claim("userName",cred.userName),
                                          new Claim("roles", rolesString)
                                  }),
                                  expires: DateTime.Now.AddHours(1),
                                  signingCredentials: signinCredentials
                      );
  
  </code></pre>
  
  <p>This is my API call using Authorization:</p>
  
  <pre class="lang-cs prettyprint-override"><code>
  [Route("api/videos/add")]
  [Authorize(Roles = "Admin")]
  [HttpPost]
  public async Task&lt;IActionResult&gt; AddVideo()
  {
      using (var reader = new StreamReader(Request.Body))
      {
          var body = await reader.ReadToEndAsync();
          var video = JsonConvert.DeserializeObject&lt;Video&gt;(body);
          await videoService.AddVideo(video);
          return Ok();
      }
  }
  
  </code></pre>
  
  <p>My NuGet Packages are:</p>
  
  <ul>
  <li>Microsoft.EntityFrameworkCore                     {3.0.0-preview5.19227.1} </li>
  <li>Microsoft.EntityFrameworkCore.Sqlite              {3.0.0-preview5.19227.1} </li>
  <li>Microsoft.AspNetCore.Authentication.JwtBearer     {3.0.0-preview4-19216-03}</li>
  <li>Microsoft.EntityFrameworkCore.Sqlite.Core         {3.0.0-preview5.19227.1} </li>
  <li>Microsoft.NETCore.Platforms                       {3.0.0-preview4.19212.13}</li>
  <li>Microsoft.AspNetCore.Mvc.NewtonsoftJson           {3.0.0-preview5-19227-01}</li>
  <li>Microsoft.AspNetCore.SpaServices.Extensions       {3.0.0-preview5-19227-01}</li>
  <li>Microsoft.AspNetCore.Identity.EntityFrameworkCore {3.0.0-preview5-19227-01}</li>
  <li>runtime.win-x64.Microsoft.NETCore.DotNetAppHost   {3.0.0-preview4-27615-11}</li>
  </ul>
  
  <p>The problem I have, is that if I call that API part, I get the error:</p>
  
  <p><strong>Information: Bearer was not authenticated. Failure message: No SecurityTokenValidator available for token:</strong> </p>
  
  <p>Any help would be much appreciated, since I can't find the error</p>