I have an app that has OAuth2
implemented. It works fine, but I'm confused with refresh_tokens
here. My app is using React
+ Redux
combination.
I know I need to check if my access_token
expired and then ask for new one using refresh_token
. Okay... But when should I refresh it? After the 401
happened or in time when some API
request that needs authorization is ready (just before send)?
I also know how to use HTTP
interceptors to get all API
requests before send or detect the 401
responses.
The problem is I'm confused how to solve the problem in Redux
flow. How to "freeze" a request for the time the token is being refreshed? Or how to repeat the request when I solve the problem on 401
response?