title: Authorize attribute does not redirect to Login page when using .NET Core 2's AddJwtBearer
body: <p>I can't make any samples to work when using the new AddJwtBearer. I have a HomeController attributed with Authorize:</p>
  <pre><code>[Authorize]
  public class HomeController : Controller
  {
      public IActionResult Index()
      {
          return View();
      }
  }
  </code></pre>
  <p>I was trying out the new ASP.NET Core AddJwtBearer and I have this code in ConfigureServices just before services.AddMvc():</p>
  <pre><code>services.AddAuthentication(opts =&gt;
  {
      opts.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
      opts.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
      opts.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
  })
  .AddJwtBearer(opts =&gt;
  {
      opts.RequireHttpsMetadata = false;
      opts.SaveToken = true;
      opts.TokenValidationParameters = new TokenValidationParameters()
      {
          IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(&quot;mysupersecretkey&quot;)),
          ValidIssuer = &quot;issuer&quot;,
          ValidAudience = &quot;audience&quot;,
          ValidateIssuerSigningKey = true,
          ValidateLifetime = true,
      };
  });
  </code></pre>
  <p>and in Configure method in Startup, I have this just before app.UseMvc()</p>
  <pre><code>app.UseAuthentication();
  </code></pre>
  <p>I was expecting it to redirect to Login page (which do not have Authorize attribute) so I can enter username and password and then create a token for succeeding use but I always get redirected to a blank page.</p>
  <p>I tried navigating Home/Index using postman, body was empty and in the header there is:</p>
  <pre><code>WWW-Authenticate →Bearer error=&quot;invalid_token&quot;, error_description=&quot;The token is expired&quot;
  </code></pre>
  <p>If I use cookie authentication, it redirects to Login page. In the previous version (UseJwtBearerAuthentication), this redirected allowing me to enter a password and get a token.</p>
  <p>Am I expecting the wrong behavior or am I missing something?</p>