Skip to main content

Supertab Connect SDK

Project description

Supertab Connect SDK

Python SDK for Supertab Connect.

PyPI License CI Python Versions Ruff

Use this package to obtain Supertab license tokens on the customer side and verify or enforce them on the merchant side.

Installation

pip install supertab-connect-sdk

Requires Python 3.12 or newer.

Customer Usage

Obtain a license token for a resource URL:

import asyncio

from supertab_connect import obtain_license_token


async def main() -> None:
    token = await obtain_license_token(
        client_id="your_client_id",
        client_secret="your_client_secret",
        resource_url="https://example.com/premium/article",
    )

    if token is None:
        print("No token required for this usage")
        return

    print(token)


asyncio.run(main())

The SDK fetches license.xml from the resource origin, finds the best matching <content> entry, and exchanges the client credentials for a license token.

Merchant Usage

Verify and record license-token usage:

import asyncio

from supertab_connect import SupertabConnect, SupertabConnectConfig


async def main() -> None:
    client = SupertabConnect(
        SupertabConnectConfig(
            api_key="your_api_key",
        )
    )

    async with client:
        result = await client.verify_and_record(
            token="your.jwt.token",
            resource_url="https://example.com/premium/article",
            user_agent="Mozilla/5.0",
            request_headers={"Accept": "text/html"},
        )

    if not result.valid:
        print(f"DENY access: {result.error}")
        return

    print("ALLOW access")


asyncio.run(main())

For request-level enforcement, use SupertabConnect.handle_request() with an httpx.Request. See the examples directory for complete merchant and customer examples.

Error Handling

Customer-side token retrieval raises SupertabConnectError when license.xml cannot be fetched or parsed, no matching content block exists, or the token endpoint fails.

Merchant-side token verification returns typed result objects instead of raising for normal invalid-token cases. Invalid tokens include a reason and a human readable error.

Typing

This package ships inline type hints and includes a py.typed marker for type checkers.

Documentation

See the Supertab Connect Python SDK docs for the full API reference.

Development

This project uses hatchling as the build backend.

See DEVELOPMENT.md for local setup, Git hooks, and CI-aligned development commands.

Links

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

supertab_connect_sdk-0.1.1.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

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

supertab_connect_sdk-0.1.1-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file supertab_connect_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: supertab_connect_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for supertab_connect_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ac501e226655cfedb676b82b6cc55649de5acfd1a407661098f4b88fa51d4dc4
MD5 d3c94958b11b734a00d39e0a191227cc
BLAKE2b-256 85124250e7affa643503c0afed0323aaaff3684f56b00d1735b8cb6535fd379c

See more details on using hashes here.

Provenance

The following attestation bundles were made for supertab_connect_sdk-0.1.1.tar.gz:

Publisher: publish-pypi.yml on getsupertab/connect-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file supertab_connect_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for supertab_connect_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63ca98a89bef34efa55f0bf8336e12c1de5fbc48ba3a15c251baad079ccb8942
MD5 e3493878ec4f1455e91e5a7367a2018b
BLAKE2b-256 a7ce4b7123905ea8dc75d2a465a442d01d6cb58034a3c9645055b8fa321818de

See more details on using hashes here.

Provenance

The following attestation bundles were made for supertab_connect_sdk-0.1.1-py3-none-any.whl:

Publisher: publish-pypi.yml on getsupertab/connect-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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