title: Ocelot with Jwt Auth
body: <p>I'm setting up authentication with jwt auth in ocelot (api gateway in asp.net core), but has not succeeded. I execute my code in postman, but the output is not as expected.</p>
  
  <p>this is ConfigureServices in Startup.cs
  I get the ApiKey from appsettings.json, and I add parameter of Jwt like issuer, audience, and IssuerSigningKey.</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
          {
              //security key
              string securityKey = Configuration.GetValue&lt;string&gt;("ApiKey:DefaultKey");
  
              //symmetric security key
              var symmetricSecurityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey));
  
              services.AddDbContext&lt;JwtEPDbContext&gt;(options =&gt;
                  options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  
              services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
                  .AddJwtBearer(options =&gt;
                  {
                      options.TokenValidationParameters = new TokenValidationParameters
                      {
                          ValidateIssuer = true,
                          ValidateAudience = true,
                          ValidateIssuerSigningKey = true,
  
                          ValidIssuer = "smesk.in",
                          ValidAudience = "readers",
                          IssuerSigningKey = symmetricSecurityKey
                      };
                  });
  
              services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
              services.AddOcelot(Configuration);
          }
  
  </code></pre>
  
  <p>and this ocelot.json</p>
  
  <pre><code>
  {
    "ReRoutes": [
      {
        "DownstreamPathTemplate": "/api/",
        "DownstreamScheme": "http",
        "DownstreamHostAndPorts": [
          {
            "Host": "localhost",
            "Port": 3000
          }
        ],
        "UpstreamPathTemplate": "/api/this-app",
        "AuthenticationOptions": {
          "SecurityKey": "0987654123456qwertysdfgvbniastrtyhajsbc8726ghuaiysdyt1276"
        }
  
      },
  
      {
        "DownstreamPathTemplate": "/api/svc_execScript2",
        "DownstreamScheme": "http",
        "DownstreamHostAndPorts": [
          {
            "Host": "10.12.4.155",
            "Port": 990
  
          }
        ],
        "UpstreamPathTemplate": "/api/test-ep"
  
      },
  
      {
        "DownstreamPathTemplate": "/api/svc_execScript2",
        "DownstreamScheme": "http",
        "DownstreamHostAndPorts": [
          {
            "Host": "10.12.4.155",
            "Port": 990
  
          }
        ],
        "UpstreamPathTemplate": "/api/test-login"
  
      }
  
    ],
    "GlobalConfiguration": {
      "BaseUrl": "https://localhost:44319"
  
    }
  
  
  }
  
  </code></pre>
  
  <p>I expect the output is 401 response, but the actual output is 200</p>