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",
    "clientId": "fayda-admin-client",
    "secretKey": "your-secret-key",
    "appId": "appId",
    "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

auth_request = AuthRequestDTO(
    individual_id="1234567890",
    individual_id_type="FIN",
    otp="123456"
)

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

Perform eKYC

from fayda_py_sdk.dto import AuthRequestDTO

ekyc_request = AuthRequestDTO(
    individual_id="1234567890",
    individual_id_type="FIN",
    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
    • CLIENT_ID: Client ID for authentication
    • SECRET_KEY: Secret key for authentication
    • APP_ID: Application 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.3.tar.gz (22.8 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.3-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fayda_python_sdk-1.0.3.tar.gz
Algorithm Hash digest
SHA256 71d7148fcec949df4d77c0e731d1eeb5dd51a0c049838012fbf8042d58753680
MD5 4117271e2d7181f15a40ecbea6c829d7
BLAKE2b-256 041936181f355d0d2541b24d4a596153177604bb2d3c3a546547dd76f18bc6cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fayda_python_sdk-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b8fbed6c689910e0583665f4e509536d6a2faa5c1c86be0240c56145efe84197
MD5 fb4405dd9abcac64786fd9815e853f12
BLAKE2b-256 3a0e5510b23969db7f2a655c940d8884e7da9c7d20df25f05aec951b9383d017

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