Iceman
Iceman

Reputation: 321

Return OAuth2 Error as JSON instead of XML

I am implementing an RESTful Webservice which returns every content formatted as JSON. I am also using Spring OAuth2, but all error messages like invalid access token etc are returned in XML format. How can I return these OAuth2 errors as JSON? By the way, the access tokens are returned as JSON String.

Upvotes: 2

Views: 1106

Answers (1)

Trynkiewicz Mariusz
Trynkiewicz Mariusz

Reputation: 2782

We have faced the same problem.

After hours and hours of configuring it on server side we have found better way to migrate this nuisance.

Error messages for OAuth2 for Spring defaults to xml but with one simple trick you can change them to JSON: by sending Accept: application/json in request headers.

Hope I helped a bit.

Upvotes: 5

Related Questions