As stated in the title, I’m looking for a solution to handle access token refresh requests.
The issue is that if multiple requests come in at the same time to create a meeting, and the access token is expired, a refresh request will be sent. Multiple calls to refresh the token will result in a failure because the first request will invalidate the others aka ‘race condition’.
I’ve read several posts on here without any good solution being provided.
My thought is to, after authorization and a exchange for access token:
- store the access token, expiry time, and refresh token in a database (for scalability).
- On an API call, fetch info from step 1. If not expired, use it.
- If expired, set a flag on the table to indicate refresh is in progress. If flag is set, wait 1 second and query again.
- Fetch refresh token, update database, remove flag.
This seems prone to errors so I’m looking for some working solutions.
Thanks!
Jaime