Solving race conditions in OAuth token refresh

Viewed 301

I have a Web App that calls another API to get OAuth Token.

The WebApp can fire multiple calls at once. The logic goes, if a token has expired, go get a new one using the refresh token. I am now facing a Race Condition problem, as the new token returned, after its being refreshed is invalidated by subsequent calls to the Refresh endpoint.

I had an attempt to use Mutex to limit one call a time. My understanding is, Mutex is used to block threads on the entire assembly, whereas I would need it to be User-Based.

Any suggestions how this can be tackled? Appreciate any advice.

0 Answers
Related