We have a react native app set up using the react-native-auth0 library and calling useAuth0.getCredentials() to refresh our tokens. I was wondering if getCredentials will wait for the access token to expire before refreshing, or if there is some buffer time before expiry where it will try to refresh while the existing access token is still valid. It would be great if this overlap could be configured.
We pass those tokens to a WebView so there could be a small delay where the WebView uses an older access token, so ideally there would be a grace period of overlap between the two access tokens.
The getCredentials() fucntion does not wait for the access token to expire, it renews the credentials with an available refresh token by having a default buffer time applied to it of 60 seconds. This buffer is configurable . You can adjust this “minimum Time To Live” (minTTL) parameter to give you a larger window as such:
const credentials = await getCredentials(300);
Otherwise, there is no “grace period” or “overlap” where two access tokens are simultaneously considered “new.” When a refresh occurs, a distinctly new access token is issued. The old one remains valid only until its original expiration time.