|
|
@ -6,26 +6,73 @@ Python Keycloak |
|
|
|
|
|
|
|
**python-keycloak** is a Python package providing access to the Keycloak API. |
|
|
|
|
|
|
|
## Installation ## |
|
|
|
# Installation |
|
|
|
|
|
|
|
### Requirements ### |
|
|
|
## Via Pypi Package: |
|
|
|
|
|
|
|
``` |
|
|
|
$ pip install python-keycloak |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
## Manually |
|
|
|
|
|
|
|
``` |
|
|
|
$ python setup.py install |
|
|
|
``` |
|
|
|
|
|
|
|
# Dependencies |
|
|
|
|
|
|
|
python-keycloak depends on: |
|
|
|
|
|
|
|
* Python 3 |
|
|
|
* [requests](http://docs.python-requests.org/en/master/) |
|
|
|
* [httmock](https://github.com/patrys/httmock) |
|
|
|
|
|
|
|
### Install ### |
|
|
|
## Tests Dependencies |
|
|
|
|
|
|
|
```bash |
|
|
|
python setup.py install |
|
|
|
``` |
|
|
|
* unittest |
|
|
|
* [httmock](https://github.com/patrys/httmock) |
|
|
|
|
|
|
|
## Bug reports ## |
|
|
|
# Bug reports |
|
|
|
|
|
|
|
Please report bugs and feature requests at |
|
|
|
https://github.com/marcospereirampj/python-keycloak/issues |
|
|
|
|
|
|
|
## Documentation ## |
|
|
|
# Documentation |
|
|
|
|
|
|
|
The documentation for python-keycloak is available on [readthedocs](http://python-keycloak.readthedocs.io). |
|
|
|
|
|
|
|
# Usage |
|
|
|
|
|
|
|
``` |
|
|
|
from keycloak import Keycloak |
|
|
|
|
|
|
|
# Configure client |
|
|
|
keycloak = Keycloak(server_url="http://localhost:8080/auth/", |
|
|
|
client_id="example_client", |
|
|
|
realm_name="example_realm", |
|
|
|
client_secret_key="secret") |
|
|
|
|
|
|
|
# Get WellKnow |
|
|
|
config_well_know = keycloak.well_know() |
|
|
|
|
|
|
|
# Get Token |
|
|
|
token = keycloak.token("user", "password") |
|
|
|
|
|
|
|
# Get Userinfo |
|
|
|
userinfo = keycloak.userinfo(token['access_token']) |
|
|
|
|
|
|
|
# Logout |
|
|
|
keycloak.logout(token['refresh_token']) |
|
|
|
|
|
|
|
# Get Certs |
|
|
|
certs = keycloak.certs() |
|
|
|
|
|
|
|
# Get RPT (Entitlement) |
|
|
|
token = keycloak.token("user", "password") |
|
|
|
rpt = keycloak.entitlement(token['access_token'], "resource_id") |
|
|
|
|
|
|
|
# Instropect |
|
|
|
keycloak.instropect(token['access_token'], rpt['rpt']) |
|
|
|
|
|
|
|
``` |