FastAPI Keycloak Integration
Welcome to fastapi-keycloak. This projects goal is to ease the integration of Keycloak (OpenID Connect) with Python, especially FastAPI. FastAPI is not necessary but is
encouraged due to specific features. Currently, this package supports only the password and the authorization_code. However, the get_current_user() method accepts any JWT
that was signed using Keycloak´s private key.
Docs
Refer to https://fastapi-keycloak.code-specialist.com/.
Adding some features:
- KeycloakToken with more datas (refresh token, expires_in, etc.)
- KeycloakRefreshToken represents the response after refresh token
- KeycloakGroup with field
attributes - Function to retrieve groups by attribute
- Update call api GET (for users and groups) with param briefRepresentation as false. This allows to get the full representation of the object.
- Update create_user and create_group
- Function to refresh token
- Override user_login to take an account more details
- Update OIDCUser to add field from attributes
This exposes all fastapi_keycloak features under fastapi_keycloak_extended.
Keycloak version
Module tested with version of keycloak:
- 16.0 (server uri must end with /auth )
- 22.0
- 26.5
Build and publish
Refer to https://packaging.python.org/en/latest/tutorials/packaging-projects/
Step:
- python -m build
- python -m twine upload --repository pypi dist/*
Change Log
[1.0.11] - 2026-03-20
Added
- Add support for Keycloak 26.5
- Add support for Python 3.14
- Add support for FastAPI 0.135.1
- Fix subGroups in Group representation by adding a recursive function to retrieve all subgroups (_with_children). This allows to get the full representation of the group with all its subgroups.
[1.0.10.1] - 2024-06-30
Added
- KeycloakToken with more datas (refresh token, expires_in, etc.)
- KeycloakRefreshToken represents the response after refresh token
- KeycloakGroup with field
attributes - Function to retrieve groups by attribute
- Update call api GET (for users and groups) with param briefRepresentation as false. This allows to get the full representation of the object.
- Update create_user and create_group
- Function to refresh token
- Override user_login to take an account more details
- Update OIDCUser to add field from attributes
Metadata
Release files for fastapi-keycloak-extended 1.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fastapi_keycloak_extended-1.0.11.tar.gz | 19.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_keycloak_extended-1.0.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.6 kB
Release files / fastapi_keycloak_extended-1.0.11.tar.gz
| Download URL | fastapi_keycloak_extended-1.0.11.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ed20eb91edc21b20e454e326b045a7c2ed0acf3947848982e19def658197d87
|
|
BLAKE2b-256 checksum How to use checksums |
498331c9f7894291390bc5c649e8b1a5fe7880239adf535074ad2eb95684bc40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / fastapi_keycloak_extended-1.0.11-py3-none-any.whl
| Download URL | fastapi_keycloak_extended-1.0.11-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d78d46f18fd1be3ea67883f2f255238c06ab37837c6a25ad848cbe66dd857352
|
|
BLAKE2b-256 checksum How to use checksums |
f8a1a5c2f446debedf358522b9d522ec9270f7b183f2db583f14e54d48ef936a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for fastapi-keycloak-extended 1.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.