private string GenerateTokenJWT(ObjTokenDTO ress) { // CREAMOS EL HEADER // var _symmetricSecurityKey = new SymmetricSecurityKey( Encoding.UTF8.GetBytes(_configuration["JWT:ClaveSecreta"]) ); var _signingCredentials = new SigningCredentials( _symmetricSecurityKey, SecurityAlgorithms.HmacSha256 ); var _Header = new JwtHeader(_signingCredentials); // CREAMOS LOS CLAIMS // var _Claims = new[] { new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), new Claim(JwtRegisteredClaimNames.NameId, ress.Id.ToString()), new Claim("PrimerNombre", ress.PriNombre), new Claim("SegundoNombre", ress.SegNombre), new Claim("PrimerApellido", ress.PriApellido), new Claim("SegundoApellido", ress.SegApellido) //new Claim(JwtRegisteredClaimNames.Email, usuarioInfo.Email), //new Claim(ClaimTypes.Role, usuarioInfo.PerfilDesc) }; // CREAMOS EL PAYLOAD // var _Payload = new JwtPayload( issuer: _configuration["JWT:Issuer"], audience: _configuration["JWT:Audience"], claims: _Claims, notBefore: DateTime.UtcNow, // Exipra a la 24 horas. expires: DateTime.UtcNow.AddDays(1) ); // GENERAMOS EL TOKEN // var _Token = new JwtSecurityToken(_Header, _Payload); return(new JwtSecurityTokenHandler().WriteToken(_Token)); }
public string GenerarTokenJWT(ObjTokenDTO ress) { string token = GenerateTokenJWT(ress); return(token); }