FDSAuth helps developers implement secure and reliable FIWARE Data Space Connector authentication in their applications.
To install FDSAuth, simply use pip
:
pip install fdsauth
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}")
# 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
For any questions or support, please reach out to us via GitHub Issues or email us at [email protected].
This work has been made by VRAIN for the CitCom.ai project, co-funded by the EU.