Documentation for pyMAuthN Python SDK

Overview

The pyMAuthN Python SDK provides an efficient and secure way to handle user verification and data retrieval in Python applications. This package simplifies integration for developers requiring authentication and user data access.

Importing the Package

To use the pyMAuthN package, import it into your Python script:

from pyMAuthN import *

Core Features

The SDK provides two key functionalities:

  1. User Verification: Confirm whether a user successfully authenticates for an application.
  2. Data Retrieval: Fetch specific user data requested by the application.

Functions

1. verifyUser

Description

This function verifies whether the user has authenticated themselves for a specific application.

Syntax

verifyUser(email_of_user, requester)

Parameters

  • email_of_user (str): The email address of the user.
  • requester (str): The name of the application requesting verification.

Returns

  • True (bool): If the user successfully authenticates.
  • False (bool): If the user fails to authenticate.

Example

is_verified = verifyUser("user@example.com", "MyApp")
if is_verified:
    print("User authenticated successfully.")
else:
    print("User authentication failed.")

2. getUserData

Description

This function retrieves specific user data requested by the application.

Syntax

getUserData(email_of_user, requested_data, requester)

Parameters

  • email_of_user (str): The email address of the user.
  • requested_data (list): A list of data fields to retrieve. Possible values:
  • "Name"
  • "Date-Of-Birth"
  • "Image" (in Base64 format)
  • "IP"
  • requester (str): The name of the application requesting the data.

Returns

  • A JSON string containing the requested data. The Image field, if requested, is represented in Base64 format.

Example

requested_data = ["Name", "Image"]
user_data = getUserData("user@example.com", requested_data, "MyApp")

print(user_data)
# Output Example:
# {
#   "Name": "John Doe",
#   "Image": "data:image/png;base64,iVBORw0KGgoAAAANS..."
# }

Notes

  • Ensure the application has permission to request and handle sensitive user data.
  • Validate Base64-encoded image data before use.
  • Use secure protocols (e.g., HTTPS) to protect transmitted data.

Error Handling

Both functions may raise exceptions if issues occur. It is recommended to handle them using try-except blocks.

Example

try:
    is_verified = verifyUser("user@example.com", "MyApp")
    if not is_verified:
        print("Authentication failed.")

    user_data = getUserData("user@example.com", ["Name"], "MyApp")
    print(user_data)
except Exception as e:
    print(f"An error occurred: {e}")

Download

Download