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.2.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.2-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: supertab_connect_sdk-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 057ba5a4473f5fe71d340f1801c7e73015824ef4b8b28a02a11b85e5d91baf1d
MD5 5233902664cd218d3fd29f4fcc874056
BLAKE2b-256 92c75aac8dbd1a3286c2aa2cbc9ee4dd3ce04abf7f3ac909a3c74389385cfe74

See more details on using hashes here.

Provenance

The following attestation bundles were made for supertab_connect_sdk-0.1.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for supertab_connect_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 38e7f0822b61b98a3a2c3389458fae08574e8639f8ae488d2f1096e68800265b
MD5 8c5ede9d96a5391901b0d1f0ecd8ef01
BLAKE2b-256 b58963801b29379eab0d1facffd905c13daa2837b2897f3d20d3563dcf9cf01f

See more details on using hashes here.

Provenance

The following attestation bundles were made for supertab_connect_sdk-0.1.2-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