public async Task <IActionResult> Token([FromBody] User user) { var identity = GetIdentity(user.Login, user.Password); if (identity == null) { Response.StatusCode = 400; return(Content("Invalid username or password.")); } var now = DateTime.UtcNow; var jwt = new JwtSecurityToken( issuer: AuthOptions.ISSUER, audience: AuthOptions.AUDIENCE, notBefore: now, claims: identity.Claims, //expires: now.Add(TimeSpan.FromMinutes(AuthOptions.LIFETIME)), expires: now.Add(TimeSpan.FromMinutes(AuthOptions.GetLifeTime())), signingCredentials: new SigningCredentials(AuthOptions.GetSymmetricSecurityKey(), SecurityAlgorithms.HmacSha256)); var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt); //var response = new //{ // access_token = encodedJwt, // username = identity.Name //}; return(Content(encodedJwt)); }