- Which SDK this is regarding: @auth0/auth0-react
- SDK Version: 1.10.2
- Platform Version: How can I check what version I’m on?
I’m using getAccessTokenSilently in a Provider to refresh access tokens in my application, and am trying to figure out how often I need to call it to ensure the access token is refreshed as soon as possible. The documentation says that getAccessTokenSilently only makes a request to Auth0 when the access token is invalid, but after some manual testing it seems to make the request before the access token becomes invalid.
I did the following tests:
- Set the access token expiration to 2 minutes & called getAccessTokenSilently every minute. I received a new access token on every call to getAccessTokenSilently.
- Set the access token expiration to 20 minutes & called getAccessTokenSilently every minute. I received a new access token after 19:05 minutes.
- Set the access token expiration to 30 minutes & called getAccessTokenSilently every minute. I received a new access token after 29:07 minutes.
It seems like if I call getAccessTokenSilently ~1 minute before the token expires it will refresh the token. Is that something I can count on & is it documented somewhere I missed?
I saw this similar post but the responses didn’t answer my question. Thanks, and let me know if there’s any useful info I can add!