Skip to content

CitCom-VRAIN/fdsauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Authentication for FIWARE Data Space (FDSAuth) PyPI - Version package workflow

FDSAuth helps developers implement secure and reliable FIWARE Data Space Connector authentication in their applications.

Table of Contents 📚

Installation 🛠️

To install FDSAuth, simply use pip:

pip install fdsauth

Usage 💻

First a DID (Decentralized Identifier) and the corresponding key-material is required. You can create such via:

mkdir certs && cd certs
docker run -v $(pwd):/cert quay.io/wi_stefan/did-helper:0.1.1

Usage example:

from fdsauth import Consumer
import requests

consumer = Consumer(
    keycloak_protocol="http",
    keycloak_endpoint="keycloak.consumer-a.local",
    keycloak_realm_path="realms/test-realm/protocol",
    keycloak_user_name="test-user",
    keycloak_user_password="test",
    apisix_protocol="http",
    apisix_endpoint="apisix-proxy.provider-a.local",
    certs_path="./certs",
)

token = consumer.get_data_service_access_token()

try:
    # Attempt to access data using the obtained service token. Get entities of type EnergyReport.
    url = f"http://apisix-proxy.provider-a.local/ngsi-ld/v1/entities?type=EnergyReport"
    headers = {
        "Accept": "application/json",
        "Authorization": f"Bearer {token}",
    }
    response = requests.get(url, headers=headers)
    response.raise_for_status()
    print(response.json())
except Exception as req_err:
    print(f"Request error occurred: {req_err}")

Development 🚀

# Create virtual env
python3 -m venv ./venv && source ./venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Build
python setup.py sdist bdist_wheel

# Local testing
pip install dist/fdsauth-X.X.X-py3-none-any.whl

Contact 📫

For any questions or support, please reach out to us via GitHub Issues or email us at [email protected].

Acknowledgments 🙏

This work has been made by VRAIN for the CitCom.ai project, co-funded by the EU.

VRAIN

CitCom.ai

About

Python authentication for FIWARE Data Space

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages