cancel
Showing results for 
Search instead for 
Did you mean: 

How to refresh a web service token in a CPI execution flow?

andres9716
Member
0 Kudos
1,040

How can I implement a token refresh mechanism in my CPI integration that queries information in the SFSF PerPerson entity and sends it to a third party web service, given that the communication token with the third party service has a lifetime of only 2 hours and do the integration runs take longer than that time? Any suggestions or ideas whether it be a groovy script or some conditional or something to implement a timer that refreshes the token before it expires in this scenario?

View Entire Topic
VijayKonam
Active Contributor
0 Kudos

If your iflow is running a loop and kept calling the 3rd party service, and that process goes over 2hrs, then your iflow should implement a tokenValidity check sub process to see if the token you currently have still valid and if not fetch a new one. However to do this you have to totally shift your auth credentials from OAuth security artifact to your iflow itself. You could store client-id and secret as security artifiact though. Usually token fetch service tells you how long the token is valid. Based on that timestamp and current timestamp, you have to chekc for the validity period everytime you are going to make a call to the target service and fetch a new token if needed, probably 5 minutes ahead of time.

I am not sure but OpenConnectors does the token refresh automatically as far as I know. Never tested though. If you use OC as connection mechanism you might be covered.