I recently updated auth0-spa-js. Since then a problem occurs with the following two symptoms.
Symptom 1: Calls to auth0.getTokenSilently()
now seem to throw an exception some of the time (perhaps after 1 hour of inactivity?). I can mitigate this by catching the exception and calling auth0.loginWithRedirect()
.
Symptom 2: I see lots of “Token could not be decoded or is missing in DB” error logs in auth0 monitoring.
Refresh Token Exchange - fertft Events "Token could not be decoded or is missing in DB" indicates this is caused by reuse of a refresh token, which seems to be entirely handled in the library itself.
Is this a bug or am I doing something wrong?
Here’s the gist of how I’m using the lib.
authClient = new Auth0Client({
clientId: CLIENT_ID,
domain: DOMAIN,
authorizationParams: {
redirect_uri: redirectUri,
audience: AUDIENCE
},
cacheLocation: "localstorage",
useRefreshTokens: true,
});
authClient.checkSession()
// other code
function callAPI(endpoint, config = {}) {
let token = undefined;
try {
token = await authClient.getTokenSilently();
} catch (error) {
console.error('Token retrieval failed:', error);
await authClient.loginWithRedirect(); // <-- New to mitigate recent issue
}
// call some api endpoint with the token
}