OAuthv2 Policy response - numeric values surrounded in double quotes by default

Not applicable

I have implemented the OAuthv2 policy to generate an OAuth token and when I receive back the response, I noticed that all of the node values are surrounded by double quotes. I would have expected fields such as expires_in to not be surrounded since they are numeric fields. Is there an option within the OAuthv2 policy to not surround numeric fields with double quotes?

0 4 153
4 REPLIES 4

It seems like that by default, the OAuthV2 policy generates the token related information in double quotes. There is no option within the policy to return numeric fields without quotes.

To return the numeric fields you can try using the below snippet in a Assign Message policy after you generate the token using OAuthV2 policy :

<Set>
 <Payload contentType="application/json" variableSuffix="%" variablePrefix="$">  
 {  ...,  
    ...,  
    "expires_in" : $oauthv2accesstoken.YOUR_OAuthV2_PolicyName.expires_in%  
 }  
 </Payload>
</Set>

Hope this helps!

Thanks for the reply. I agree that an Assign Message Policy can be used to adjust the response. It just seems odd that the default policy would wrap what are clearly numeric fields with double quotes. It forces the consumer to add additional logic to expose what I would consider normal behaviour.

Yes, that's true 🙂

Not applicable

There is no policy configuration to transform the response. The previous answer is a good solution if required. I will pass the concern along to engineering.