Session Account Too many sessions?

Hi guys,

On my keycloak server I activated the Service account and I realize that there’re a lot of sessions created for this user. For instance, after the first login is created 22 service accounts sessions… and after a while this number increases a lot since a new session is created every 15s (+/-).

Is this behavior normal? If not how can I change this?
Thanks in advance

Some screenshots

Are you calling the token endpoint /auth/realms/{realm_name}/protocol/openid-connect/token each time before you make a request? A common case is that people use their service account to make API requests, calling the token endpoint before each request, or when the access token expires. If you are using it this way, sessions will build up. A way to prevent this would be to call the token endpoint once, and then use the refresh token to get new access tokens until the refresh token expires. That will prevent buildup of sessions like this.

1 Like

IIRC the refresh token was removed from the response when it’s client flow, and service accounts are client flow. This is to be more OAuth2 spec conform.

But anyway, the access token can be used as long as it is valid (and this is intended!). Only when it is expired, one will need to re-authenticate.