This library is no longer maintained. Please use the official ORY Hydra package.
Python wrapper for the ORY Hydra OAuth2 and OpenID Connect server REST API.
Disclaimer: This library is still in alpha state!
pip install hydra-client
from hydra_client import HydraAdmin
hydra = HydraAdmin("http://localhost:4445")
login_request = hydra.login_request("challenge")
redirect_to = login_request.accept(subject="username")See also the example login/consent provider.
All code is formatted using black. Tests and static checks can be run with tox:
tox
The hydra-client uses Betamax for mocking and recording HTTP interactions.
Run Hydra in a Docker container:
docker run \
-it \
--rm \
-e "DSN=memory" \
-e "URLS_SELF_ISSUER=http://localhost:4444/" \
--name hydra \
-p 4445:4445 \
-p 4444:4444 \
oryd/hydra:v1.0 \
serve all --dangerous-force-http
Create a new OAuth2 client:
docker exec \
-it hydra \
hydra clients create \
--endpoint http://localhost:4445 \
--id test-client \
--secret test-secret \
--callbacks http://client.localhost
Re-Record Betamax cassettes:
BETAMAX_RECORD_MODE=all tox