Possible to return the same access_token till expiration

Hello, Some developers doesn't manage correctly access token. They ask a Bearer token before each call of apis.
The Apigee OAuthV2 policy generates on each call a new access token.
This generate a useless filling of Cassandra cluster 😞
Is there a way to configure OAuthV2 Policy to return always the same access token till it is not expired yet ?
Thank you

Yves

0 2 200
2 REPLIES 2

I am not sure if Apigee OAuth policy can generate the same access token multiple times.

=

As a workaround, maybe we can wrap GenerateOAuthV2 policy in-between LookupCache and PopulateCache with few Conditions.

PopulateCache will create a cache of OAuthV2 Response and we will map the cache expiry time to the token expiry time.

LookupCache will check for a cache with the CacheKey as request.content or client_id.

  1. If the cache is empty. It will invoke GenerateToken policy and will create a cache using PopulateCache.
  2. If the cache is not empty. It will skip GenerateToken & PopulateCache policies and just returns the old token to the user.

I did not try this approach. I will update this post with a working proxy if required.

Thank you for this proposal, but I'm not sure that it's a good solution. Managing cache will increase RMP memory consumption.

I'm very suprise that Apigee doesn't check is there is already a valid access token in Cassandra for a given client_id before generate a new one !!

This could be an option no ?

Any other suggestion ?

Thank you

Yves