Automated OIDC authentication client with PKCE support for any Keycloak or OAuth2 provider.
- 🔐 PKCE (Proof Key for Code Exchange) - Secure authorization code flow
- 🤖 Automated browser login - No manual intervention needed
- 🔌 Provider agnostic - Works with any OIDC/OAuth2 provider
- 🎯 Pluggable strategies - Simple forms, EGI, or custom authentication flows
- 🐍 Simple API - Easy integration in Python scripts
Install uv package manager, e.g. Standalone installer for macOS or Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/envuv sync
uv run playwright install chromiumSimple form (default)
uv run oidc-auth \
--issuer https://keycloak.example.com/auth/realms/realm \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_SECRET \
--username user@example.com \
--password yourpassword \
--headlessEGI Check-in
uv run oidc-auth \
--issuer https://aai-dev.egi.eu/auth/realms/egi \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_SECRET \
--username user@cern.ch \
--password yourpassword \
--strategy egi \
--headlessRun modes
# Normal mode (headless browser)
uv run oidc-auth --headless ...
# Debug mode (headless browser with screenshots and verbose logging)
uv run oidc-auth --debug --headless ...
# Debug mode without headless (visible browser with screenshots and verbose logging)
uv run oidc-auth --debug ...Simple form
from oidc_auth_client import OIDCAuthClient
client = OIDCAuthClient(
issuer_url="https://keycloak.example.com/auth/realms/realm",
client_id="client-id",
client_secret="secret",
username="user@example.com",
password="password",
)
tokens = client.get_tokens()
print(tokens['access_token'])EGI Check-in
from oidc_auth_client import OIDCAuthClient
from oidc_auth_client.strategies import EGIStrategy
client = OIDCAuthClient(
issuer_url="https://aai-dev.egi.eu/auth/realms/egi",
client_id="your-client-id",
client_secret="your-secret",
username="user@cern.ch",
password="password",
auth_strategy=EGIStrategy(),
)
tokens = client.get_tokens()Custom strategy
from oidc_auth_client.strategies import AuthStrategy
class CustomStrategy(AuthStrategy):
def login(self, page, username, password):
page.fill('#custom-user', username)
page.fill('#custom-pass', password)
page.click('#custom-submit')
client = OIDCAuthClient(..., auth_strategy=CustomStrategy())- Generates PKCE code verifier and challenge (SHA-256)
- Creates authorization URL with PKCE parameters
- Automates browser login via Playwright using selected strategy
- Exchanges authorization code for tokens using code verifier
- Returns tokens (access_token, id_token, refresh_token)
- simple - Basic username/password form (default)
- egi - EGI Check-in multi-step authentication
- custom - Implement your own
AuthStrategy
MIT
