Skip to main content

Python SDK for ContactsManager API authentication and token generation

Project description

ContactsManager Python SDK

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/contactmanager.git
cd contactmanager/sdk/py

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

# Run tests
pytest

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
    • 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

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.0.0.tar.gz (4.8 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.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for contactsmanager-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d8f6119febccb0e3b4e71f001be1e2d7790ab5afe08ad1643f7dc02aae64fe7c
MD5 78c384588bd9bbb33b31655885add5f2
BLAKE2b-256 51c2288c9b2e60cbb7bbba01375dbd699dda0d5e192daf8ac759b227252683b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for contactsmanager-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0053a030b0ddb1925f56fc126afbe4022ae9406041fb7860d98f69820808ed0c
MD5 e85e8ca9fb95832d9a4fe63f0ff3c64f
BLAKE2b-256 31e0b13a4d1871e3a32b04518c61575d7393bcad1ffcc5aa531181561fa8850c

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