Error handling 当您使用OAuth2.0构建restful服务时,是要使用自定义的错误字段还是OAuth2.0的错误字段?
很难解释清楚Error handling 当您使用OAuth2.0构建restful服务时,是要使用自定义的错误字段还是OAuth2.0的错误字段?,error-handling,oauth-2.0,restful-authentication,Error Handling,Oauth 2.0,Restful Authentication,很难解释清楚 在构建restful web服务时,通常会为错误定义两个字段:error\u code和error\u msg 将OAuth2.0与grant_type=password一起使用时,您将看到它已经定义了这两个字段。例如,{“error”:“unauthorized”,“error_description”:“xxx”}。拼写必须像这样精确,因为它受到OAuth 2.0协议的限制 问题是,当您将2组合到一个服务器端应用程序中时,您通常只使用OAUTH的{“error”:“my biz
另一个(可选)问题是,如果您是一个swagger.io用户,您将选择什么方式来生成更好的文档 我现在自己回答这个问题:我定义了我的biz error对象,它的错误字段是oauth2的超集。Oauth2的error_描述在我的error response对象中被视为“error msg for developers” 公共类错误结果{
@JsonProperty("error")
private String errorCode;
@JsonProperty("error_description")
private String devErrMsg;
@JsonProperty("error_description_for_user")
private String userErrMsg;
@JsonProperty("exception_id")
private String exceptionId;
}