Extract the credentials expiry based on consumer key

We are having a list of Credentials loaded as part of AccessEntity.ChildNodes.access-entity-app-oauth.App. Based on the matching consumer key, we would like to pull up the expiry of a credential matched on the basis of consumer key(already extracted as client_id) and pass it to the header something like:-

<Variable name="oauth-oauth-expiry" type="string">
  <XPath>/App/Credentials/Credential[ConsumerSecret/text()={client_id}/ExpiresAt</XPath>
</Variable>

What is the best way to achieve it?

0 1 172
1 REPLY 1

The XPath element within ExtractVariables is not, today, a message template. In other words you cannot reference a context variable in that XPath.

The good news is that there's a feature coming soon (b/123246424) that would allow you to execute a dynamic XPath today using the message template concept. But that's not available yet.

Today, you can try one of these approaches:

  1. Convert the message to JSON and use JSONPath, and use a dynamic jsonpath query.
  2. Use a Java callout to specify the dynamic XPath. https://github.com/DinoChiesa/ApigeeEdge-Java-Xpath