0

I would like to Cache the Client OAUTH token and use the same token for the subsequent requests in the Azure Logic Apps. Only when the token is expired, I want to hit the access token URI and fetch the new token. How is this possible in Logic Apps? Please assist me..

Carter
  • 697
  • 5
  • 22

1 Answers1

0

There is no built-in support for this and logic apps have no way to save state in themselves between runs that I am aware of.

An approach I have taken recently is to create a cache logic app which uses a service bus queue for persistence, with a second timed logic app calling the first on a polling interval to make sure the token stays live, implementing the logic as follows:

  • receive an http request
  • dequeue from the queue and parse the token as a variable
  • if the time to live minus the last requested time is less than the timer interval, make a call to the refresh endpoint to acquire a fresh token, replace the token variable and update the last requested time
  • requeue the token
  • return the token content to the caller

This logic app must be set with a max parallelism of 1 to ensure that there is always a token on the queue to read, as more than one instance running concurrently would leave the queue empty at the time it is requested.

Tom W
  • 5,108
  • 4
  • 30
  • 52