Hello There,
I’m facing an issue where I’m unable to get a cached value using lookup cache policy as explained below:
I have two proxies (proxy1 and proxy2) that are deployed under same API product and each proxy hit a different target endpointpoint:
Proxy1 : calls authenticate API.
Proxy2 : calls accounts API
In proxy1, once I get the response back, I’m caching the token using the below polices in sequence to the response flow:
ExtractVariables:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract_IAM_Token">
<DisplayName>Extract IAM Token From IAM Response</DisplayName>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="AccessToken">
<JSONPath>$.access_token</JSONPath>
</Variable>
<Variable name="AccessTokenType">
<JSONPath>$.token_type</JSONPath>
</Variable>
<Variable name="AccessTokenExpiry">
<JSONPath>$.expires_in</JSONPath>
</Variable>
<Variable name="AccessTokenScope">
<JSONPath>$.scope</JSONPath>
</Variable>
</JSONPayload>
<Source clearPayload="false">response</Source>
<VariablePrefix>varIAMToken</VariablePrefix>
</ExtractVariables>
PopulateCache:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PopulateCache async="false" continueOnError="false" enabled="true" name="IAM_MG_Token">
<DisplayName>Populate IAM Token From Cache</DisplayName>
<Properties/>
<CacheKey>
<KeyFragment>mgAccessToken</KeyFragment>
<KeyFragment ref="apigee.access_token"/>
</CacheKey>
<Scope>Exclusive</Scope>
<ExpirySettings>
<TimeoutInSec>3600</TimeoutInSec>
</ExpirySettings>
<Source>varIAMToken.AccessToken</Source>
</PopulateCache>
LookupCache (used to confirm that I can get the token):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="Get_IAM_Token">
<DisplayName>Lookup IAM Token From Cache</DisplayName>
<Properties/>
<CacheKey>
<KeyFragment>mgAccessToken</KeyFragment>
<KeyFragment ref="apigee.access_token"/>
</CacheKey>
<Scope>Exclusive</Scope>
<AssignTo>varIAMToken.AccessToken</AssignTo>
</LookupCache>
AssignMessage:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Return_MG_Token">
<DisplayName>Remove IAM Token From the Response Body</DisplayName>
<Set>
<Payload contentType="application/json">
{
"AccessToken":"{varIAMToken.AccessToken}"
}
</Payload>
<StatusCode>200</StatusCode>
<ReasonPhrase>OK</ReasonPhrase>
</Set>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</AssignMessage>
Which gives me the token. However, for proxy2, I need to lookup the cache so I can make the call to my accounts API with that token. I’m adding the below policy to the request flow :
LookupCache:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="Get_IAM_Token">
<DisplayName>Lookup IAM Token From Cache</DisplayName>
<Properties/>
<CacheKey>
<KeyFragment>mgAccessToken</KeyFragment>
<KeyFragment ref="apigee.access_token"/>
</CacheKey>
<Scope>Global</Scope>
<AssignTo>varIAMToken.AccessToken</AssignTo>
</LookupCache>
However, I’m not getting the token back and the cache comes empty.
I’m not sure why am i missing in my polices or if i’m doing something incorrect. I really appreciate your help.
Thank you
