WSO2 API Manager Auth error content type

馋奶兔 提交于 2019-12-11 03:05:36

问题


I have WSO2 API Manager configured and everything seems to work fine.

The only issues bothering me is that in case of an Auth exception, the API manager always returns the response with XML content type, e.g.,

<ams:fault xmlns:ams="http://wso2.org/apimanager/security"><ams:code>900904</ams:code><ams:message>Access Token Inactive</ams:message><ams:description>Access failure for API: /exchange, version: 1.0 with key: 1139a466ebfd825aca953ad7259b9f45</ams:description></ams:fault>

In case of client communicates with my web service with JSON format, the XML response will look a little bit strange.

Is there any ideas how to make API Manager provide error response in JSON format?


回答1:


This has been addressed in recent versions of API Manager. Auth errors can be set to json format by adding or updating the error_message_type property in WSO2HOME/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml:

<property name="error_message_type" value="application/json"/>

I've found this also requires JSONBuilder and JSONMessageFormatter to be selected for the json content type in axis2.xml (which is the default setting).

For older versions, this article explains how to manually do the same.



来源:https://stackoverflow.com/questions/17687483/wso2-api-manager-auth-error-content-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!