Skip to main content

Python SDK for ContactsManager API authentication and token generation

Project description

ContactsManager Python SDK

PyPI version Build Status License: MIT Python Test Coverage

A Python SDK for the ContactsManager API that handles authentication and token generation.

Installation

pip install contactsmanager

Usage

from contactsmanager import ContactsManagerClient

# Initialize the client
client = ContactsManagerClient(
    api_key="your_api_key",
    api_secret="your_api_secret",
    org_id="your_org_id"
)

# Generate a token for a user
token_response = client.generate_token(
    user_id="user123",
    device_info={  # Optional
        "device_type": "mobile",
        "os": "iOS",
        "app_version": "1.0.0"
    }
)

print(f"Token: {token_response['token']}")
print(f"Expires at: {token_response['expires_at']}")

Features

  • Simple API for generating JWT tokens
  • Type hints for better IDE support
  • Comprehensive test coverage
  • Support for custom token expiration

Advanced Usage

Custom Token Expiration

By default, tokens expire after 24 hours (86400 seconds). You can customize this:

# Generate a token that expires in 1 hour
token_response = client.generate_token(
    user_id="user123",
    expiration_seconds=3600  # 1 hour
)

Requirements

  • Python 3.8+
  • PyJWT>=2.0.0

Development

Setting up development environment

# Clone the repository
git clone https://github.com/arpwal/contactsmanager-py.git
cd contactsmanager-py

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

Running Integration Tests

Integration tests validate the SDK against real-world scenarios, including server-side API key validation.

Local Setup

  1. Create a .env file with your test configuration:

    # Copy the template file
    cp env.template .env
    
    # Edit the .env file with your credentials
    # The configuration is a JSON string in the TEST_CONFIG variable
    TEST_CONFIG='{"api_key":"your_api_key","api_secret":"your_api_secret","org_id":"your_org_id","api_base_url":"https://api.contactsmanager.io"}'
    
  2. Run the integration tests:

    ./run_integration_tests.sh
    

Releasing new versions

The SDK uses an automated process for releases:

  1. Update the version in contactsmanager/__init__.py using the provided script:

    ./bump_version.sh 0.1.1
    
  2. Commit and push the change to the main branch:

    git add contactsmanager/__init__.py
    git commit -m "Bump version to 0.1.1"
    git push origin main
    
  3. The GitHub Actions workflow will:

    • Run all tests across multiple Python versions
    • Run integration tests
    • Create a new GitHub release with the version tag
    • Build and publish the package to PyPI

Alternatively, you can manually create a new release by:

  1. Creating and pushing a git tag:

    git tag -a v0.1.1 -m "Release version 0.1.1"
    git push origin v0.1.1
    
  2. The GitHub Actions workflow will handle the rest

License

MIT License

About ContactsManager.io

ContactsManager.io provides a platform for app developers to integrate social features into their applications. Our SDK ensures that contact information stays with users only, with multi-layer encryption and military-grade security to prevent spam and data misuse.

For more information and documentation, visit contactsmanager.io.

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

contactsmanager-1.2.4.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

contactsmanager-1.2.4-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file contactsmanager-1.2.4.tar.gz.

File metadata

  • Download URL: contactsmanager-1.2.4.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for contactsmanager-1.2.4.tar.gz
Algorithm Hash digest
SHA256 a3ed28563418af46acfab5dbb9c0b1d240770bcc1b2682788b7a90ecdf19868a
MD5 0353a030105d5a10a19a8c8532647ab8
BLAKE2b-256 75928a05f1d5fe72567b5ea487df873a3505de54c3978fbfba89b9c165e2a064

See more details on using hashes here.

File details

Details for the file contactsmanager-1.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for contactsmanager-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c2d116dd81b408d24093d439e12744d73f44ed5a4e002f98377e79d37893c7a6
MD5 1e45d636d9bcbfc33008caa6ffb7bc45
BLAKE2b-256 6e809543558ee1f24605812169e4f8eeec7e31978ca6cd04c45f8db134e2c0e8

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