Код: Выделить всё
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
using (UserAuthentication objUser = new UserAuthentication())
{
//var user = db.ApiUsers.Where(o => o.UserName == context.UserName && o.UserPasswd == context.Password).FirstOrDefault();
var user = objUser.ValidateUser(context.UserName, context.Password);
if (user == "false")
{
context.SetError("invalid_grant", "Username or password is incorrect");
if(context.ErrorDescription == "Username or password is incorrect")
{
}
context.Response.StatusCode = 200;
return;
}
else
{
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
await Task.Run(() => context.Validated(identity));
}
}
}
Код: Выделить всё
{
"error": "invalid_grant",
"error_description": "Username or password is incorrect"
}
Код: Выделить всё
{
"Message": "invalid_grant",
"Message_Description": "Username or password is incorrect"
}
Подробнее здесь: https://stackoverflow.com/questions/725 ... r-response