Skip to main content

Keycloak Authenticator

Project description

Keycloak-Basic

All the libraries I found for Keycloak are outdated and not nearly generic enough, so here's a new one.

Documentation

Installing

python -m pip install keycloak-basic

Usage

from keycloak import Keycloak, AccessToken, UserInfo

keycloak: Keycloak = Keycloak(
    "http(s)://<host>:<port>", # Keycloak server URL with no trailing path
    "<realm name>", # Name of realm to authenticate in
    "<client id>", # Client ID
    client_secret = "<client secret" # Client secret, if present
)

token: AccessToken = keycloak.login(
    "<username>", # User username
    "<password>" # User password
) -> AccessToken

keycloak.authenticated # Boolean, true if logged in
keycloak.isScoped("scope") -> bool # True if current token has scope

info: UserInfo = keycloak.userinfo() -> UserInfo object

keycloak.refresh() -> AccessToken # Refreshes connection
keycloak.logout() # Logs out

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keycloak-basic-1.1.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

keycloak_basic-1.1.0-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page