简体   繁体   English

有谁知道如何在Spring Security oauth2中更改响应错误格式?

[英]Does anyone know how to change response error format in Spring security oauth2?

I am using Spring security oauth2. 我正在使用Spring安全oauth2。 By default oauth2 returns it's own error format like {error : "Invalid_grant", error_description : "something"} . 默认情况下,oauth2返回它自己的错误格式,例如{error : "Invalid_grant", error_description : "something"} I want to change it my own custom format so in my application, it remains consistent. 我想更改它自己的自定义格式,因此在我的应用程序中,它保持一致。 Can anyone please help me? 谁能帮帮我吗? I have gone through lots of links but didn't find any suitable solution till now. 我已经遍历了很多链接,但直到现在都找不到合适的解决方案。

What you get as a result is a JSON document. 结果,您得到的是JSON文档。

  1. Look at Jackson or Gson libraries for example to parse(deserialize) JSON documents. 例如,查看Jackson或Gson库来解析(反序列化)JSON文档。 You can get data values 1 by 1 or deserialize into a class instance. 您可以将数据值1乘1或反序列化为类实例。
  2. Once you parse modify the data as you wish 解析后,根据需要修改数据
  3. Use the same library Jackson or Gson to write(serialize) a new JSON document. 使用相同的库Jackson或Gson编写(序列化)新的JSON文档。
  4. Jackson may also produce as output XML, YAML and CSV documents Jackson可能还会生成XML,YAML和CSV文档作为输出

https://github.com/FasterXML/jackson-core https://github.com/FasterXML/jackson-core
https://github.com/google/gson https://github.com/google/gson

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM