DEV Community

Discussion on: Secure Svelte with Keycloak

Collapse
 
stilet profile image
stilet

Great article! And how to use a silent token update in your algorithm?

Collapse
 
matejbucek profile image
Matěj Bucek

Hi, thank you very much.
The method this.keycloak.updateToken(number) silently updates your tokens, when the refresh token is still non-expired. Otherwise it makes redirect to your Keycloak Authorization Endpoint and user have to log in.
In the latest version of my code, you can see that I've set this.keycloak.onTokenExpired to an anonymous lambda function, that calls the update method. The onTokenExpired method is called by Keycloak itself, so you don't have to worry about updating your token anymore.