Python SDK for Ethiopia's Fayda National Digital ID (eSignet)
Project description
fayda-sdk
Python SDK for Ethiopia's Fayda National Digital ID (eSignet).
Install
pip install fayda-sdk
Quick Start
from fayda_sdk import FaydaClient
client = FaydaClient(
client_id=os.environ["FAYDA_CLIENT_ID"],
private_key_b64=os.environ["FAYDA_PRIVATE_KEY"],
redirect_uri="https://myapp.com/auth/callback",
)
# Step 1: Generate login URL
result = client.auth.get_authorization_url()
session["fayda_state"] = result.state
session["fayda_verifier"] = result.code_verifier
return redirect(result.url)
# Step 2: Handle callback
user = client.userinfo.get_from_code(
code=request.args["code"],
state=request.args["state"],
expected_state=session["fayda_state"],
code_verifier=session["fayda_verifier"],
)
Environment Variables
| Variable | Description |
|---|---|
FAYDA_CLIENT_ID |
Your eSignet client ID |
FAYDA_PRIVATE_KEY |
Base64-encoded JWK private key |
FAYDA_REDIRECT_URI |
OAuth callback URL |
FAYDA_SANDBOX |
Set to "true" for sandbox mode (optional) |
Async Support
Use AsyncFaydaClient for async/await:
async with AsyncFaydaClient(...) as client:
user = await client.userinfo.get_from_code(...)
Error Handling
from fayda_sdk.errors import FaydaAuthError, FaydaTokenError
try:
user = client.userinfo.get_from_code(...)
except FaydaAuthError:
return "Invalid state — possible CSRF attack"
except FaydaTokenError as e:
return f"Token error: {e}"
Full Documentation
See FAYDA_SDK_SPEC.md for the complete API reference.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fayda_sdk-0.1.0.tar.gz
(8.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
fayda_sdk-0.1.0-py3-none-any.whl
(12.0 kB
view details)
File details
Details for the file fayda_sdk-0.1.0.tar.gz.
File metadata
- Download URL: fayda_sdk-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e014be8bcfdd76bafe01219bff0f95307de3dbdd4f838e8b34f468b57aa1427
|
|
| MD5 |
ea7d9ac0b773399d4040d6610a37fcbe
|
|
| BLAKE2b-256 |
53b81e3e02f5098ec874c9f93c9d62526ce4c2eeffd5ac6dd61eaf0cbf2c8d8e
|
File details
Details for the file fayda_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fayda_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f3c37e7d2da16d599ce9f3fab267a7618383bc96fb76655416b12459793f7bd
|
|
| MD5 |
6a5777af218eb3d7ed4b2aafba1d5b47
|
|
| BLAKE2b-256 |
9d0a4fd527a49c816dbb90f8650aa35d6ac1cf6ec6ea54a6b5c2a418c6905a66
|