Skip to main content

Hi Mulesoft,

We deployed api gateway on premise with policies on it and it's working fine. Now we have cases which require to modify default policy violation responses, for example in External OAuth2 Provider the default responses are in REST JSON e.g.

{

"error": "missing_access_token",

"description": "The access token is missing."

}

but we like it to be in REST XML. Is this possible? How?

 

Thank you

4 个回答
  1. 2015年10月5日 02:20

    Hi @vinzonwsl,

     

    Unfortunately the current policy implementation returns a JSON error when there's a policy violation, unless it's an auto-generated SOAP proxy, in which case it returns XML.

     

    It is possible to achieve what you want through a custom policy though, by modifying the current policy template and transforming the payload to XML in the oauth2ErrorResponse processor chain, which is the one that handles the policy violation and prepares the response.

     

    To get hold of the policy template for the External OAuth Provider enforcement policy, when the policy is applied, it'll be stored in the policies folder in the distribution. You can create the custom policy based on that and modify it to add the transformation to XML in the onUnaccepted processor chain. I don't think the policy yaml and XML are available now unless you contact support. You can check this documentation to know more about custom policies.

     

    HTH,

    Eva

0/9000