Skip to main content

Python SDK for Fayda IDA (Identity Authentication) - OTP, Authentication and eKYC services

Project description

Python IDA SDK

PyPI version Python 3.8+ License: MIT

Python SDK for Fayda IDA (Identity Authentication) services. Provides a simple and intuitive interface for OTP generation, authentication, and eKYC (electronic Know Your Customer) operations.

Features

  • OTP Management: Request and manage OTPs for Fayda ID verification
  • Yes/No Auth: Yes/No authentication using OTP
  • eKYC Services: Perform electronic KYC to retrieve verified identity information
  • Secure Cryptography: Built-in support for RSA-OAEP, AES-GCM, and JWT signatures
  • PKCS12 Key Management: Support for PKCS12 certificate and key files
  • Easy Configuration: Configure via environment variables or dictionary
  • Comprehensive Error Handling: Robust error handling and logging

Installation

Install from PyPI:

pip install fayda-python-sdk

Or install from source:

git clone https://github.com/National-ID-Program-Ethiopia/python-ida-sdk.git
cd python-ida-sdk
pip install -e .

Quick Start

Usage

Basic Configuration

from fayda_py_sdk import ConfigBuilder
from fayda_py_sdk.dto import OtpRequestDTO, AuthRequestDTO

# Configure from environment variables
config = ConfigBuilder().from_env()

# Or configure from dictionary
config = ConfigBuilder().from_dict({
    "partnerId": "fayda-partner-demo",
    "fayda.base.url": "https://fayda.baseurl.et",
    "mispLicenseKey": "your-license-key",
    "partnerApiKey": "your-api-key",
    "ida.reference.id": "PARTNER",
    "p12.path": "keys",
    "p12.password": "pass@123",
    "ida.ssl.verify": False
})

# Build client
client = config.build()

Request OTP

from fayda_py_sdk.dto import OtpRequestDTO

otp_request = OtpRequestDTO(
    individual_id="1234567890",
    individual_id_type="FIN",
    otp_channel=["email"]
)

response = client.request_otp(otp_request)
print(response)

Yes/No Auth

from fayda_py_sdk.dto import AuthRequestDTO

# Fayda ID: UIN for FIN or VID for FAN
auth_request = AuthRequestDTO(
    individual_id="1234567890",  # Fayda ID
    individual_id_type="UIN",     # UIN for FIN or VID for FAN
    otp="123456"
)

response = client.yes_no_auth(auth_request)
print(response)

Perform eKYC

from fayda_py_sdk.dto import AuthRequestDTO

# Fayda ID: UIN for FIN or VID for FAN
ekyc_request = AuthRequestDTO(
    individual_id="1234567890",  # Fayda ID
    individual_id_type="UIN",     # UIN for FIN or VID for FAN
    otp="123456"
)

response = client.perform_ekyc(ekyc_request)
print(response)

Configuration

The SDK can be configured using:

  1. Environment Variables:

    • PARTNER_ID: Partner ID
    • FAYDA_BASE_URL: Base URL for Fayda API
    • MISP_LICENSE_KEY: MISP License Key
    • PARTNER_API_KEY: Partner API Key
    • IDA_REFERENCE_ID: IDA Reference ID
    • P12_PATH: Path to PKCS12 keys directory
    • P12_PASSWORD: Password for PKCS12 files
    • IDA_SSL_VERIFY: Enable/disable SSL verification (true/false)
  2. Dictionary: Pass configuration as a dictionary to ConfigBuilder.from_dict()

  3. Manual Configuration: Use ConfigBuilder().set_config(key, value) for individual settings

Key Files

The SDK expects PKCS12 key files in the keys directory (default: keys/). The files should be named:

  • {partnerId}-partner.p12 - Partner private key and certificate
  • {partnerId}-partner.cer - Partner certificate

Running Examples

# Make sure your keys are in the keys/ directory
# Update configuration in example.py or set environment variables

python example.py

Requirements

  • Python 3.8 or higher
  • PKCS12 key files (.p12 format) for partner authentication
  • Valid Fayda API credentials

Error Handling

The SDK includes comprehensive error handling. All exceptions are logged and raised with descriptive messages. Common errors include:

  • RuntimeError: For authentication failures, certificate errors, or API errors
  • ValueError: For invalid configuration or key file issues
  • Exception: For network or parsing errors

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support

For issues, questions, or contributions, please use the GitHub Issues page.

For direct support, contact:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for a list of changes and version history.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fayda_python_sdk-1.0.4.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fayda_python_sdk-1.0.4-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file fayda_python_sdk-1.0.4.tar.gz.

File metadata

  • Download URL: fayda_python_sdk-1.0.4.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for fayda_python_sdk-1.0.4.tar.gz
Algorithm Hash digest
SHA256 0639944966f92e2ff0203918e9b5456ba1efcd27874aba416d932cfeb97d59da
MD5 8bd32213351e52583cab3250d4a538ef
BLAKE2b-256 7fa967ceecbd11bf57e95ce076d0581d45df0ef10fbc6dc4b4a8bb627dfa5c62

See more details on using hashes here.

File details

Details for the file fayda_python_sdk-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for fayda_python_sdk-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dee17ee3ff59089c65665947e0925a0df673d54a4153c3a983ffe6274b28064c
MD5 06cb27caccd0eb0f3220cc8502783f6e
BLAKE2b-256 c0647692a919f6e8b4a85d53f19f9bafc6db44942bb9318e96d9f739e8b83e50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page