Estou recebendo esse erro quando tento executar no postman
{
"": [
"The input was not valid."
]
}
tentei colocar o attributo FromBody mas o erro permanace:
public async Task<IActionResult> Token([FromBody] LoginModel model)
meu body da requição http:
{
"Login":"admin",
"Password":"123"
}
meu metodo post:
[HttpPost]
public async Task<IActionResult> Token([FromBody] LoginModel model)
{
if (ModelState.IsValid)
{
var result = await _signInManager.PasswordSignInAsync(model.Login, model.Password, true, true);
if (result.Succeeded)
{
var direitos = new[]
{
new Claim(JwtRegisteredClaimNames.Sub, model.Login),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
};
var chave = new SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes("alura-webapi-authentication-valid"));
var credenciais = new SigningCredentials(chave, SecurityAlgorithms.HmacSha256);
var token = new JwtSecurityToken(
issuer: "Alura.WebApp",
audience: "Postman",
claims: direitos,
signingCredentials: credenciais,
expires: DateTime.Now.AddMinutes(30)
);
var tokenString = new JwtSecurityTokenHandler().WriteToken(token);
return Ok(tokenString);//200
}
return Unauthorized(); //401
}
return BadRequest(); //400
}