asp.net-web-apiowin-middlewarexml-formatting

OAuth Bearer Token - Use XML format


I am using OWIN middleware to issue access token for my ASP.NET WebApi project.

The token issued is always in Json format despite removing the Json formatter from the formatter collection.

I tried setting the XML formatter to be at the top of the collection list.

I also tried setting both content-type and accept headers to be application/xml

What am I missing to enable the token response to be in XML format? Any suggestions would be much appreciated.

Thanks


Solution

  • The proposed standard of The OAuth 2.0 Authorization Framework by IEFT states that -

    "The parameters are included in the entity-body of the HTTP response using the "application/json" media type as defined by [RFC4627]. The parameters are serialized into a JavaScript Object Notation (JSON) structure by adding each parameter at the highest structure level. Parameter names and string values are included as JSON strings. Numerical values are included as JSON numbers. The order of parameters does not matter and can vary."

    So response is implemented as a JSON as per the proposed standard. In order to get the response in XML, one should write the HttpModule to convert JSON to XML as described in this answer - https://stackoverflow.com/a/29035498/9721400