Skip to content

Instantly share code, notes, and snippets.

@xgp
xgp / get-keycloak-active-sessions.py
Created July 25, 2024 17:10 — forked from nickbabkin/get-keycloak-active-sessions.py
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
#!/bin/bash
echo '=================================================='
echo '===============Install necessary tools==============='
echo '=================================================='
sudo yum update
sudo yum install git make flex bison libtool automake openssl-devel libevent libevent-devel python-devel gcc-c++ byacc java-1.7.0-openjdk ant
echo '=================================================='