Which policy to be used to send the generated access token (client_credentials) back to consumer?

I have a Raise Fault policy in the flow which currently sends the generated access token back to the consumer of my API but what is the problem with this approach is when I go to Analytics->Proxy performance and select the OAuth API Proxy, it shows 100% Traffic Errors although the OAuth API successfully generated the access token in all the cases.

I strongly believe this is because I used Raise Fault policy hence internally Analytics considers it's a error flow hence Analytics data logged accordingly for all the success cases.

If some one would ask me to use Assign Message Policy instead of raise Fault then I can't because in my flow I've many other policies attached after Raise Fault policy which currently sends back access token to consumer.

Appreciate your response.

Many thanks!

Solved Solved
0 2 230
1 ACCEPTED SOLUTION

Don't use RaiseFault to send back success messages.

You are correct that your use of RaiseFault is causing the analytics to show 100% errors.

you wrote

If some one would ask me to use Assign Message Policy instead of raise Fault then I can't because in my flow I've many other policies attached after Raise Fault policy which currently sends back access token to consumer.

I don't agree. Use AssignMessage., or use the implicitly-assigned value that you get from OAuthV2-GenerateAccessToken. You say "I can't" but I suspect the reason you cannot use the correct approach is because you have co-opted the FaultRules elements to handle normal flow. This is wrong. This is why your analytics are incorrect. Don't use the RaiseFault policy for successful flows.

Your flow can look like this:

<Request>
  ...
</Request>
<Response>
  <Step>
    <Name>OAuthV2-GenerateAccessToken</Name>
    <!-- response.content gets assigned --> 
  </Step>


  <Step>
    <!-- modify response.content as desired -->
    <Name>JS-GroomTokenResponse</Name>
  </Step>


  <Step>
    <Name>Other-policy-here</Name>
  </Step>
  
  ...
  
</Response>

Don't use RaiseFault.

View solution in original post

2 REPLIES 2

Don't use RaiseFault to send back success messages.

You are correct that your use of RaiseFault is causing the analytics to show 100% errors.

you wrote

If some one would ask me to use Assign Message Policy instead of raise Fault then I can't because in my flow I've many other policies attached after Raise Fault policy which currently sends back access token to consumer.

I don't agree. Use AssignMessage., or use the implicitly-assigned value that you get from OAuthV2-GenerateAccessToken. You say "I can't" but I suspect the reason you cannot use the correct approach is because you have co-opted the FaultRules elements to handle normal flow. This is wrong. This is why your analytics are incorrect. Don't use the RaiseFault policy for successful flows.

Your flow can look like this:

<Request>
  ...
</Request>
<Response>
  <Step>
    <Name>OAuthV2-GenerateAccessToken</Name>
    <!-- response.content gets assigned --> 
  </Step>


  <Step>
    <!-- modify response.content as desired -->
    <Name>JS-GroomTokenResponse</Name>
  </Step>


  <Step>
    <Name>Other-policy-here</Name>
  </Step>
  
  ...
  
</Response>

Don't use RaiseFault.

Thank you @Dino-at-Google . I will try your suggested approach. Appreciate it.