Keycloak node js admin client refresh token lifespan

157 views
Skip to first unread message

Valerii Petryniak

unread,
Oct 25, 2022, 10:12:41 AM10/25/22
to Keycloak User
In documentation there is such code:
```js
// Periodically using refresh_token grant flow to get new access token here setInterval(async () => { const refreshToken = tokenSet.refresh_token; tokenSet = await client.refresh(refreshToken); kcAdminClient.setAccessToken(tokenSet.access_token); }, 58 * 1000); // 58 seconds
```

1. My question is: is it safe to use such code? What if refresh token expires?

2. And if yes then, is it safe if I will call this function just sometimes when I need to make requests via keycloak-nodejs-admin-client(lets say once in a while):
```js
async () => { const refreshToken = tokenSet.refresh_token; tokenSet = await client.refresh(refreshToken); kcAdminClient.setAccessToken(tokenSet.access_token); }
```
Will refresh token expire and will app crash?
Reply all
Reply to author
Forward
0 new messages