This question talks about the theory and work flow behind using refresh tokens to prolong the life of the access token.
As the linked answer suggest, I should do expiry check (1) when the app is opened, and (2) periodically every x hour, and refresh the access token if it is near expiring.
My question is, how exactly do I implement this in React, or any front end code?
Suppose my single page app has 3 pages, each with 5 components.
When the user opens the app, it could be any of the 3 URLs, which component (if any) should be responsible for this check? Should this block any of the other components from fetching data until the verification is done?
Similarly, which component (if any) should do the period checking?
I'm thinking that as long as the above 2 is correctly executed, it will not be possible to end up in a situation where a user makes a request with an expired access token. At least, I can't think of an edge case that an expired access token will be sent. Is this correct?