Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Unable to trap invalid_client error in Fault Rule

I have been trying so many stuff but I've really been stuck for more than a day on this issue.

I'm calling a proxy that calls GenerateAccessToken on supplying a 1) grant_type 2) client_id 3) client_secret. I can get a token but I want to return a customized response if any of these 3 parameters are invalid.

Apigees responses for invalid data in these 3 params:

{"ErrorCode" : "invalid_client", "Error" :"ClientId is Invalid"}

{"ErrorCode" : "invalid_client", "Error" :"Client credentials are invalid"}

{"ErrorCode" : "invalid_request", "Error" :"Unsupported grant type : client_credentials1"}

I have an AssignMessage policy that customizes my application's response to the sender that will be trigger based on this FaultRule:

<FaultRule name="checkErr2">

<Step> <Name>AM-IncorrectHeaderBodyInfo</Name>

<Condition> SOME CONDITION </Condition>

</Step>

</FaultRule>

What is the proper Condition I have to provide in the Fault Rule? I'm very frustrated as none of these work:

oauthV2.MyOathPolicy.failed = true

<Condition>(oauthV2.oauth-boc.failed = true) OR (oauthv2.oauth-boc.fault.name Matches "invalid") OR (oauthv2.oauth-boc.fault.cause = "ClientID is Invalid")</Condition>

The documentation on this page https://docs.apigee.com/api-platform/reference/policies/get-oauth-v2-info-policy is very inadequate, I am afraid to say.

0 7 392
7 REPLIES 7