Skip to main content

usethatapp

Python SDK for usethatapp.com. usethatapp.com is an OpenID Connect provider: this SDK logs a user in through the marketplace, identifies them by a privacy-preserving sub, and tells you their live license entitlement for your app.

Framework-agnostic. The SDK never touches your web framework — it takes and returns plain strings and one JSON-able flow_state dict. You wire the three framework-specific bits yourself (read the callback query params, store flow_state in your session, issue the redirect). Works with Django, Flask, FastAPI, Starlette, Dash, Streamlit, plain WSGI, a CLI — anything. Runtime deps: httpx, joserfc.

v2.0 is a breaking rewrite. The v1 launch-envelope / user_key / get_version handoff is replaced by standard OAuth2/OIDC. See CHANGELOG.md and Migrating from v1 below.

How it works

  1. Login (redirect). Start a login with begin_login(), send the user to usethatapp.com to authenticate, and finish in your callback with complete_login(). You get a UtaSession carrying the user's sub (a stable, per-app, pseudonymous id — no PII) and OAuth tokens.
  2. Entitlement (Bearer query). Call get_entitlement(access_token) whenever you need the user's current license. It's always authoritative — a canceled license stops being entitled immediately.

sub is pairwise: stable for a user within your app, but different in every other app, so it can't be correlated across apps. Use it as your local user key — and key off sub, never an email (we never share one).

Install

pip install usethatapp

Python 3.9+. Runtime deps: httpx, joserfc. No web framework required.

Settings

Read from django.conf.settings if Django is installed and configured, otherwise from environment variables.

Name Required Purpose
UTA_CLIENT_ID yes Your app's OAuth client id (from the usethatapp.com dashboard).
UTA_REDIRECT_URI yes Your registered callback URL.
UTA_CLIENT_SECRET yes* Client secret. *Omit for a public (browser/native) PKCE client.
UTA_CLIENT_SECRET_PATH no Read the secret from a mounted file instead (Render/k8s/Fly).
UTA_ISSUER no Defaults to https://www.usethatapp.com/o.
UTA_API_URL no Defaults to https://www.usethatapp.com.
UTA_SCOPES no Defaults to openid entitlements.
UTA_CLOCK_SKEW_SECONDS no ID-token validation leeway. Defaults to 60.
UTA_REQUEST_TIMEOUT_SECONDS no Defaults to 10.

Public API

from usethatapp import (
    begin_login,        # -> (authorization_url, flow_state)
    complete_login,     # (code=, state=, flow_state=) -> UtaSession
    get_entitlement,    # (access_token) -> Entitlement
    get_entitlement_async,
    refresh,            # (refresh_token) -> UtaSession
    userinfo,           # (access_token) -> {"sub": ...}
    logout_url,         # (id_token=, post_logout_redirect_uri=) -> str
    purchase_url,       # (price_id, *, next=, ref=, email=) -> str  (no network)
    manage_url,         # (*, next=) -> str                          (no network)
    get_app_info,       # () -> AppInfo        (anonymous public API)
    get_app_info_async,
    get_prices,         # () -> AppPrices      (anonymous public API)
    get_prices_async,
    UtaSession,         # sub, access_token, refresh_token, id_token, expires_at, ...
    Entitlement,        # entitled, version, product_id, product_public_id, status, is_trial, ...
    AppInfo,            # client_id, name, tagline, listing_mode, url, marketplace_url
    Price,              # public_id, product_id, product_name, amount, currency, ...
    AppPrices,          # client_id, app_name, has_free_tier, prices
    # errors:
    UtaError, UtaConfigError, UtaDiscoveryError, UtaAuthError,
    UtaTokenError, UtaPermissionError, UtaServiceNotEnabledError,
    UtaNotFoundError, UtaOrderProcessingError, UtaLicenseCanceledError,
    UtaServerError,
)

Quickstart — any framework

from usethatapp import begin_login, complete_login, get_entitlement

# 1) Start login — however your framework spells "redirect":
auth_url, flow_state = begin_login()
save_to_session("uta_flow", flow_state)        # JSON-able dict
return redirect(auth_url)

# 2) In your callback (reads ?code=...&state=... off the request).
#    On cancel/deny the provider sends ?error=... and no code — handle it first:
if read_query("error"):
    return redirect("/")   # login was canceled
session = complete_login(
    code=read_query("code"),
    state=read_query("state"),
    flow_state=load_from_session("uta_flow"),
)
save_to_session("uta_sub", session.sub)
save_to_session("uta_access_token", session.access_token)

# 3) Anywhere you gate features. Gate on product_public_id — the opaque
#    prod_… id that matches Price.product_id from get_prices():
ent = get_entitlement(load_from_session("uta_access_token"))
if ent.entitled and ent.product_public_id == "prod_...":
    ...

Runnable per-framework demos live under examples/. They are documentation only — nothing framework-specific ships in the package.

Error mapping

get_entitlement maps status codes to typed exceptions:

Status Exception Meaning
401 UtaTokenError Access token invalid/expired — re-auth/refresh.
403 (insufficient_scope) UtaPermissionError Token lacks the entitlements scope.
403 (service_not_enabled) UtaServiceNotEnabledError The Hosted sign-in add-on is switched off for this app. No retry, refresh, or re-consent will help — enable it on the app's manage page at www.usethatapp.com (Integration panel).
400 UtaError Client not linked to an app (misconfig).
429 UtaServerError Rate limited — back off; e.retry_after carries the server's Retry-After seconds (or None).
5xx UtaServerError Retriable with backoff; e.retry_after when the server sent one.

All inherit from UtaError — catch that for a single except clause. UtaServiceNotEnabledError subclasses UtaPermissionError, so existing except UtaPermissionError blocks keep working unchanged.

License Key API — bring your own auth

If you keep your own auth (Auth0, Clerk, homegrown) and use UseThatApp purely as merchant of record, skip the OIDC flow entirely and verify purchases with license keys. Server-side only; set UTA_CLIENT_SECRET (UTA_REDIRECT_URI is not needed for this mode).

from usethatapp import get_order, regenerate_license_key, validate_license_key

# 1) The buyer returns from checkout with ?uta_order=... — exchange it
#    for their key and link it to YOUR signed-in user. No email matching.
order = get_order(request.GET["uta_order"])   # raises UtaOrderProcessingError → retry briefly
your_db.save(user=current_user, license_key=order.license_key,
             license_id=order.license_id)

# 2) Any time you need the truth (app start, feature gate, cron):
state = validate_license_key(stored_key)      # LicenseState
if state.entitled: ...                        # cache against state.period_end
# state.is_trial: in a free trial — entitled, nothing charged yet, and
# period_end is the conversion date. Show a banner; gate nothing extra.
# canceled purchases return entitled=False, status="canceled" — an
# answer, not an exception. UtaNotFoundError means a key that was
# never issued for your app.

# 3) Compromised key? Rotate it — the old key dies instantly:
state = regenerate_license_key(license_id)    # state.license_key is the new key

Buyers can always re-view their key on their UseThatApp management page, so "I lost my key" needs no support ticket and no rotation.

usethatapp.com can sell your app from your own website: hosted checkout links, a buyer management page, and a public pricing API. The SDK helpers are thin — the URL builders make no network calls, and the two GET functions hit anonymous endpoints (no auth, CORS-enabled), so they work even on a marketing page that never logs anyone in.

Gate an upgrade CTA on the entitlement, then send the user to checkout:

from usethatapp import get_entitlement, manage_url, purchase_url

ent = get_entitlement(load_from_session("uta_access_token"))
if not ent.entitled:
    # Hosted checkout. `next` must be an HTTPS URL on your registered
    # domain (validated server-side); omit it to land on your Login URL.
    return redirect(purchase_url("prc_...", next="https://yourapp.example/welcome"))

# Existing buyers manage (or cancel) their plan on usethatapp.com:
billing_link = manage_url(next="https://yourapp.example/account")

Render pricing from the live API instead of hardcoding — sellers can change prices anytime:

from usethatapp import get_prices

pricing = get_prices()          # anonymous — no token needed
for price in pricing.prices:
    per = f"/{price.frequency}" if price.is_recurring else " one-time"
    print(f"{price.product_name}: {price.amount} {price.currency}{per}")
    print(f"  buy: {price.buy_url}")   # ready-made hosted checkout link

Price.amount is a decimal string (e.g. "10.00") — parse with decimal.Decimal if you need arithmetic. Price.product_id is the opaque prod_… identifier to gate features on after purchase — compare it against Entitlement.product_id or Entitlement.product_public_id: since the platform's identifier cutover they are a permanent equal-valued alias pair carrying the same prod_… value, so gate on either.

Notes: UseThatApp is the merchant of record (checkout, tax, refunds are handled for you). Purchases are currently US-only. External sales is in beta — buy links return 404 until it's enabled for your app. Full guide: docs.usethatapp.com.

Signing out

Sign-out is RP-initiated: redirect the user to logout_url(id_token=…). Both outcomes — they confirm, or they choose "Stay signed in" — return to your post_logout_redirect_uri, so you can't tell which happened from the redirect alone.

So don't clear your session when you start logout. Reconcile on return using the token instead: a confirmed logout revokes it, so your next get_entitlement() raises UtaTokenError (401) — drop the token then. If they stayed signed in, the token is still valid and they keep their session. Clearing eagerly logs the user out of your app even when they chose to stay.

Migrating from v1

v1 v2
get_user(payload) (decrypt envelope) begin_login() + complete_login() (OIDC)
UtaUser.user_key UtaSession.sub (pairwise, stable per app)
get_version(user_key) -> str get_entitlement(access_token) -> Entitlement
RSA keys (UTA_PRIVATE_KEY, market key) OAuth client (UTA_CLIENT_ID/UTA_CLIENT_SECRET)
UTA_APP_ID (gone — the client id identifies your app)
uta_launch_view Django decorator (gone — wire your own callback view)

Register an OAuth client and redirect URI in your usethatapp.com developer dashboard to get UTA_CLIENT_ID / UTA_CLIENT_SECRET.

License

MIT — see LICENSE.

Metadata

Release files for usethatapp 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for usethatapp 2.3.0
File Size Uploaded Provenance Actions
usethatapp-2.3.0.tar.gz 45.5 kB Without provenance Details for usethatapp-2.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for usethatapp 2.3.0
File Interpreter ABI Platform Actions
usethatapp-2.3.0-py3-none-any.whl Python 3 none any Details for usethatapp-2.3.0-py3-none-any.whl

Total release size: 73.2 kB

Release files / usethatapp-2.3.0.tar.gz

Download URL usethatapp-2.3.0.tar.gz
Size 45.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e442040ac222cbbeb800601301dca73cb0a997b0d41f91a6ea70d812e54e62e2
BLAKE2b-256 checksum
How to use checksums
68bf99a0d1d9b02c7864948a911edbbad54354d72f2dff96502c0de28fc85538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.8

Release files / usethatapp-2.3.0-py3-none-any.whl

Download URL usethatapp-2.3.0-py3-none-any.whl
Size 27.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56ecf47925329a13ac5d298d34128389e0e1908f6f6698016153634d6038ae62
BLAKE2b-256 checksum
How to use checksums
ca8e803b826a6f82ad0a3d6a25db8abe4ce5b9f7685b30cea3c43b0e2543491b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.8

Security for usethatapp 2.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page