python-hydra-sdk icon indicating copy to clipboard operation
python-hydra-sdk copied to clipboard

Hydra SDK for Python

Python Hydra SDK Build Status Coverage Status

This package provides a Python SDK for Hydra OAuth2 and OpenID Connect server made in Go.

Installing

pip install hydra-sdk

Basic usage

Documentation is still in progress...

from hydra import Hydra

# First, create a Hydra client
hydra = Hydra(publichost='http://localhost:4444',adminhost='http://localhost:4445', client='client-server', secret='secret-server')

# Get an access token
token = hydra.get_access_token()

# Create a client
client = Client(
    name='new-client',
    secret='client-secret',
    scopes=['devices', 'products'],
    redirect_uris=['http://localhost/callback'],
)
client_id = hydra.clients.create(client).id

# Get a client
client = hydra.clients.get(cliente_id)

Covered API

Hydra API coverage is a work in progress. You can check what is already developed in the following list:

  • Public Endpoints
    • [ ] JSON Web Keys Discovery
    • [ ] OpenID Connect Discovery
    • [ ] The OAuth 2.0 authorize endpoint
    • [x] Revoke OAuth2 tokens
    • [ ] The OAuth 2.0 token endpoint
    • [ ] OpenID Connect Userinfo
  • Administrative Endpoints
    • [x] List OAuth 2.0 Clients
    • [x] Create an OAuth 2.0 client
    • [x] Get an OAuth 2.0 Client.
    • [x] Update an OAuth 2.0 Client
    • [x] Deletes an OAuth 2.0 Client
    • [ ] Retrieve a JSON Web Key Set
    • [ ] Update a JSON Web Key Set
    • [ ] Generate a new JSON Web Key
    • [ ] Delete a JSON Web Key Set
    • [ ] Fetch a JSON Web Key
    • [ ] Update a JSON Web Key
    • [ ] Delete a JSON Web Key
    • [x] Get consent request information
    • [x] Accept an consent request
    • [x] Reject an consent request
    • [x] Get an login request
    • [x] Accept an login request
    • [x] Reject a login request
    • [x] Lists all consent sessions of a user
    • [x] Revokes all previous consent sessions of a user
    • [x] Revokes consent sessions of a user for a specific OAuth 2.0 Client
    • [x] Logs user out by deleting the session cookie
    • [x] Invalidates a user's authentication session
    • [x] Flush Expired OAuth2 Access Tokens
    • [x] Introspect OAuth2 tokens

License

Python Hydra SDK is released under MIT license.