Dec 23, 2014

How to change authentication failure response message content type in WSO2 API Manager






With WSO2 API Manager, when calling an API with an expired tokens we are getting a SOAP response like following by default, the content type is XML.



    
       
           900904
           Access Token Inactive
           Access failure for API: /Authenticate, version: 1.0.0 with key: bb50cf86703ef76d4f4c3018ca74f115
       
    


If an application is expecting JSON response, API Manager has to send JSON version of authentication failure response. You can do this by changing
to
in [API_Manager]/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml file After the change you will get

{
    "fault": {
        "code": "900904",
        "message": "Access Token Inactive",
        "description": "Access failure for API: /weatherApi, version: 1.0.0 with key: asPZCocnJt7m6KnAqGNNPH97fdga"
    }
}