I am working on a web application (JS 4 API) that uses the identity manager to manage credentials to log in to a secured service. How can I get the tokens on secured services to refresh when they are expired?
From what I've read, it seems that the credentials have a built-in timer to automatically refresh the credentials. Based on the documentation, I think that I need to listen for the "token-change" event on the credentials and then fire off a response to update the token on the map layers. I tried listening for the "token-change" event on the credentials, but I can't seem to pick up the event and I haven't been able to find any examples that use this event. I also don't see where the credentials are stored with the layer to refresh them in the service.
Does anyone have any suggestions for picking up the event when the token on the credentials is refreshed and updating the credentials in the map layers?
My app with token authentication is very rudimentary in that I funnel all errors through a generic error handling function for everything in the app. One of the checks is to find the word "token". If it does, it assumes the token is expired, so deletes it and then sends them to the log in screen. Very basic but better than making the user refresh the app.
I'm also hoping someone else has a better solution.