How to not add apigee custom attribute if value in "ref" is null or empty

When i am generating an access token using OauthV2 Policy, i do not want to add a custom attribute if it is not supplied from my API. By default i see that the customer attribute is added with an empty string even the value of the ref in that attribute is null or empty.

<Attributes>

<Attribute name="test" ref="request.formparam.test" display="false"/> </Attributes>

In this case, i do not want to add the attribute test to my token metadata if request.formparam.test is not being passed. How can i achieve this.

1 1 207
1 REPLY 1

Hi @dharihar. Welcome to the Apigee community.

You could use a SetOAuthV2Info policy after the access token is generated. In this policy you could set the "optional" custom attribute. Also for this policy you would need to add a Condition in the flow so that it is triggered only if your custom attribute is present. This should help you easily achieve your desired result.