Monday, May 16, 2016

How to change API Managers authentication failure message to message default content type.

The error response format sent from WSO2 gateway is usually in xml format. Also if need we can change this behavior. To do this we have extension point to customize message error generation. For auth failures throttling failures we have handler to generate messages.

For auth failures following will be used.

The handler can be updated to dynamically use the content Type to return the correct response.
Once you changed it will work for XML and JSON calls.

Change the file to add a dynamic lookup of the message contentType i.e,

<sequence name="auth_failure_handler" xmlns="">

<property name="error_message_type" value="application/json"/>
<sequence key="cors_request_handler"/>

<sequence name="auth_failure_handler" xmlns="">

<property name="error_message_type" value="get-property('transport', 'Content-Type')"/>
<sequence key="cors_request_handler"/>

No comments:

Post a Comment