简体   繁体   中英

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

I am using Spring security oauth2. By default oauth2 returns it's own error format like {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.

  1. Look at Jackson or Gson libraries for example to parse(deserialize) JSON documents. You can get data values 1 by 1 or deserialize into a class instance.
  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.
  4. Jackson may also produce as output XML, YAML and CSV documents

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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