https://github.com/westphahl/hydra-login-consent-python
Example implementation for the User Login and Consent flow of ORY Hydra version 1.0.x in Python
https://github.com/westphahl/hydra-login-consent-python
Last synced: 11 months ago
JSON representation
Example implementation for the User Login and Consent flow of ORY Hydra version 1.0.x in Python
- Host: GitHub
- URL: https://github.com/westphahl/hydra-login-consent-python
- Owner: westphahl
- License: mit
- Created: 2018-12-16T15:06:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-16T02:07:36.000Z (over 3 years ago)
- Last Synced: 2025-06-05T10:50:34.813Z (12 months ago)
- Language: Python
- Size: 13.7 KB
- Stars: 28
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ory - Ory Hydra Python login/consent provider example
README
Hydra login/consent provider - Python
======================================
This is an example implementation for the User Login and Consent flow of
[ORY Hydra](https://www.ory.sh/docs/hydra/) version 1.7.x in Python.
**Requirements: Python >= 3.7**
This example is using the official
[ory-hydra-client](https://github.com/ory/sdk/tree/master/clients/hydra/python) Python library.
Running locally
---------------
Use the official Hydra Container image:
```shell
docker run \
-it \
--rm \
--network="host" \
-e "DSN=memory" \
-e "URLS_SELF_ISSUER=http://127.0.0.1:4444/" \
-e "URLS_CONSENT=http://127.0.0.1:5000/consent" \
-e "URLS_LOGIN=http://127.0.0.1:5000/login" \
-e "LOG_LEAK_SENSITIVE_VALUES=true" \
--name hydra \
-p 4445:4445 \
-p 4444:4444 \
oryd/hydra:v1.7 \
serve all --dangerous-force-http
```
Afterwards you can install the dependencies and run the example application:
```shell
$ pip install -r requirements.txt
$ flask run
```
## Testing an example flow
```sh
docker exec hydra \
hydra clients create \
--endpoint http://127.0.0.1:4445 \
--id auth-code-client \
--secret secret \
--grant-types authorization_code,refresh_token \
--response-types code,id_token \
--scope openid,offline \
--callbacks http://127.0.0.1:5555/callback
```
```sh
docker exec hydra \
hydra token user \
--client-id auth-code-client \
--client-secret secret \
--endpoint http://127.0.0.1:4444/ \
--port 5555 \
--scope openid,offline \
--audience auth-code-client
```
See also the instructions in the
[5 minute tutorial](https://www.ory.sh/docs/hydra/5min-tutorial) for testing
the various [OAuth 2.0 grant types](https://oauth.net/2/grant-types/).