Skip to content

Instantly share code, notes, and snippets.

View nickbabkin's full-sized avatar

Nick Babkin nickbabkin

  • Gelato
View GitHub Profile
@nickbabkin
nickbabkin / get-keycloak-active-sessions.py
Created July 25, 2024 14:53
Get total number of active Keycloak sessions per client
'''
USAGE:
1) Create client in Keycloak and enable client authentication + service account roles for it
2) Assign "view-realm" role from realm-management client on "service account roles" tab for the client
3) Replace keycloak_url and realm_name variables with your Keycloak base dir
4) Export client credentials into $CLIENTID and CLIENTSECRET env variable
5) python get-keycloak-active-sessions.py
'''
import requests