public IActionResult Login(LoginRequest request) { AuthHandler auth = new AuthHandler(_dbService); if (auth.HandleAuthenticateAsync(request) != Accepted()) { return(BadRequest("wrong credentials")); } var claims = new[] { new Claim(ClaimTypes.NameIdentifier, request.login), new Claim(ClaimTypes.Name, "PJATK") }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SecretKey"])); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var token = new JwtSecurityToken ( issuer: "Me", audience: "Students", claims: claims, expires: DateTime.Now.AddMinutes(10), signingCredentials: creds ); return(Ok(new { token = new JwtSecurityTokenHandler().WriteToken(token), refreshToken = Guid.NewGuid() })); }