title: JWT Token Expiration time failing .net core
body: <p>I am trying to implement Token Based Authentication through refresh tokens and JWT in .NET Core 2.1.</p>
  
  <p>This is how I am implementing the JWT Token:</p>
  
  <p>Startup.cs</p>
  
  <pre><code>services.AddAuthentication(option =&gt;
      {
          option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
          option.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
          option.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
      }).AddJwtBearer(options =&gt;
      {
          options.SaveToken = true;
          options.RequireHttpsMetadata = true;
          options.TokenValidationParameters = new TokenValidationParameters()
          {
              ValidateIssuer = true,
              ValidateAudience = true,
              ValidAudience = Configuration["Jwt:Site"],
              ValidIssuer = Configuration["Jwt:Site"],
              IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:SigningKey"]))
          };
  
          options.Events = new JwtBearerEvents
          {
              OnAuthenticationFailed = context =&gt;
              {
                  if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
                  {
                      context.Response.Headers.Add("Token-Expired", "true");
                  }
                  return Task.CompletedTask;
              }
          };
      });
  </code></pre>
  
  <p>Token Generation:</p>
  
  <pre><code>var jwt = new JwtSecurityToken(
                  issuer: _configuration["Jwt:Site"],
                  audience: _configuration["Jwt:Site"],
                  expires: DateTime.UtcNow.AddMinutes(1),
                  signingCredentials: new SigningCredentials(signinKey, SecurityAlgorithms.HmacSha256)
                  );
  
          return new TokenReturnViewModel()
          {
              token = new JwtSecurityTokenHandler().WriteToken(jwt),
              expiration = jwt.ValidTo,
              currentTime = DateTime.UtcNow
          };
  </code></pre>
  
  <p>I am getting he correct values in Response.</p>
  
  <p><a href="https://i.stack.imgur.com/z4Ffp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/z4Ffp.jpg" alt="enter image description here"></a></p>
  
  <p>But after a minute I set the same token for authorization in Postman and it works.
  If the token has expired it shouldn't.</p>
  
  <p>I am using bearer tokens as authentication.</p>
  
  <p>What am I doing wrong? Need direction.</p>