当身份验证失败时,在 GrantResourceOwnerCredentials 方法中返回SimpleAuthorizationServerProvider
;
context.SetError("invalid_grant", "The user name or password is incorrect.");
但是,我需要使用 TEntity
类返回我自己的 JSON 响应,任何帮助将不胜感激。
这会为你解决问题吗?
context.SetError("MyCustomError", JsonConvert.SerializeObject(new removeit()
{
NAME = "1",
name2 = "2",
name3 = "3"
}));
返回
{
"error": "MyCustomError",
"error_description": "{"NAME":"1","name2":"2","name3":"3"}"
}