Spring-security-oauth: InvalidTokenException serialized as XML instead of JSON

Created on 6 Oct 2016  路  3Comments  路  Source: spring-projects/spring-security-oauth

When testing failure scenarios for token the InvalidTokenException is being sent back as XML instead of JSON. I get the following:

<InvalidTokenException><error>invalid_token</error><error_description>Cannot convert access token to JSON</error_description></InvalidTokenException>

when I expect JSON. Is there some config option I'm missing here?

waiting-for-triage

Most helpful comment

setting header attribute "Accept" : "application/json" solved the problem. Is there any better way to implement this as default behavior. I tried to override WebMvcConfiguration to set content negotiation strategy as FixedContentNegotiationStrategy with default content type as "application/json", which didn't work.

All 3 comments

any resolution of config option for JSON serialization?

setting header attribute "Accept" : "application/json" solved the problem. Is there any better way to implement this as default behavior. I tried to override WebMvcConfiguration to set content negotiation strategy as FixedContentNegotiationStrategy with default content type as "application/json", which didn't work.

@kshitij-kasliwal Did you get any workaround on this ?

Was this page helpful?
0 / 5 - 0 ratings