Custom storage tokenManager setItem fires more often than needed

We are using a custom storage provider in our tokenManager, parsing some cookies ourselves. In our setItem method for the token manager, we are also generating a randomly created ID for another use case. This ID appears to change throughout the day causing us some issues. This leads me to believe this setItem function gets called more than when the user first logs in.

When does setItem get called? Why is it happening more than once? Is there anyway within setItem to know what changed or why so we can handle changes correctly?

Hi there. Possibly this could be happening due to autorenew. See the docs here:

By default, the tokenManager will attempt to renew tokens before they expire. If you wish to manually control token renewal, set autoRenew to false to disable this feature. You can listen to expired events to know when the token has expired.

So potentially, unless you set autoRenew to false, it could be running and causing that setItem method to fire

thanks for that. it looks like it attempts autorenew 30 seconds before expiration, we have a 24 hour expiration on our access tokens… ah ha, it appears the id token was renewed when the setItem ran again, which makes sense… ok, I think we can determine if the access token changes by comparing the incoming value to what’s in our cookie.

Do you know if when the ID token is renewing, do we get the access token as well? or will we only get the id token value? (i’ll have to find out the hard way here if I have to debug)

No problem! And at the 1 hour mark when it renews the ID token, it should only renew the ID token, not access. (Unless of course you set the access token to a 1 hour expiry)

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.