Skip to main content

I'm looking for some guidance on how to handle multiple backend processes attempting to access the RingCentral api for the same account simultaneously. Each separate process runs independently, on a separate schedule, and has its own token refresh logic built in. For the most part, this all works well. But every once in a while I end up with a token that is "expired". The only way to resolve it is to have the user log back into our app so the token can refresh again.

This happens very infrequently, but often enough that it's an annoyance both to me and to the customers impacted. But it's infrequent enough that it's hard to track down the issue. I am suspicious that my two separate processes are colliding with each other, getting fired off at the same time, and the refreshed token in one process overrides the refreshed token in the other one, and the system ends up with an invalid token at the end. Is that a possibility?

What is the best way to handle this scenario?

Just a little background - the two processes run continuously, on separate schedules, and check the user's account for new data. One process runs every 5 minutes, and the other process runs every 2 minutes.

Hi Matt,

Sorry for the delayed response. Are you looking for solutions for password flow or OAuth authentication? There must be different approach for different authentication method. So let me know.


One way I can suggest is sharing the access token among multiple backend process. If you are using API calls in backend process with access token, which I am assuming, you can share that with the multiple calls. One of the way is using Caching the token for a particular period of time and using the token among different processes.

That will avoid colliding and overriding issue you are facing


Reply