Skip to main content

vercel-connect-bundle

This is a version of vercel-connect with third-party dependencies bundled. For normal use, install the unbundled vercel-connect package instead: https://pypi.org/project/vercel-connect/

vercel-connect

Python SDK for Vercel Connect, a credential broker for third-party APIs.

You exchange your deployment's token for a short-lived credential for an upstream service. Your project never stores provider secrets, and Connect owns the OAuth client, PKCE, refresh, and revocation server-side.

pip install vercel-connect

Usage

import httpx2 as httpx
from vercel.connect import ConnectAppTokenSubject, get_token

token = await get_token("github/my-app", subject=ConnectAppTokenSubject())

async with httpx.AsyncClient() as client:
    await client.get(
        "https://api.github.com/user/repos",
        headers={"Authorization": f"Bearer {token}"},
    )

The same surface is available synchronously, with identical names and arguments:

from vercel.connect.sync import ConnectAppTokenSubject, get_token

token = get_token("github/my-app", subject=ConnectAppTokenSubject())

Use a plain with block and vercel.connect.sync together; mixing an async call into a sync session, or the reverse, is rejected.

Subjects

Whose authority the credential carries:

Subject Authority Needs
ConnectAppTokenSubject() The integration itself An installation
ConnectUserTokenSubject(id=...) One named end user That user's consent
ConnectJwtBearerTokenSubject(sub=...) A user asserted by your app Pre-established trust
ConnectTokenExchangeSubject(token=...) A credential you already hold The inbound token

app is one shared credential per installation: simple, always available, but ambient authority. user preserves the provider's own permission model per person and names them in the provider's audit log, at the cost of a consent flow.

Subjects are typed values rather than plain strings because three of the four carry their own fields, so subject="user" could not say which user:

ConnectUserTokenSubject(id="u_123", issuer="https://idp.example.com")
ConnectJwtBearerTokenSubject(sub="u_123", additional_claims={"tenant": "acme"})

Value types

Every type on this surface is a frozen Pydantic model, so you get validation on construction, autocompletion, exact match/case narrowing, model_dump() for logging, and immutability, which means a subject cannot be mutated after a credential has been cached against it:

detail = ConnectGitHubAppInstallationAuthorizationDetail(permissions=["contents:read"])
detail.model_dump()                    # {'org': None, 'permissions': ('contents:read',), ...}
detail.permissions = ["admin"]         # ConnectValidationError: frozen

Construction is by keyword, a misspelled field is an error rather than a silently dropped value, and every rejection raises ConnectValidationError, so you never need to catch Pydantic's own error type. Containers of strings accept any container and store a tuple; a bare string is rejected rather than expanded into one entry per character:

get_token(..., scopes="repo:read")     # ConnectValidationError, and a type error
get_token(..., scopes=["repo:read"])   # correct

Authorization as control flow

The two "required" errors are not bugs, they are states with a remedy:

from vercel.connect import (
    ConnectUserTokenSubject,
    UserAuthorizationRequiredError,
    get_token,
    start_authorization,
)

subject = ConnectUserTokenSubject(id=user_id)
try:
    token = await get_token("linear/my-app", subject=subject)
except UserAuthorizationRequiredError:
    authorization = await start_authorization(
        "linear/my-app", subject=subject, return_url="https://myapp.com/cb"
    )
    return redirect(authorization.url)

A CLI or headless process has nowhere to redirect to, so it asks for a device code and polls. Each outcome is its own error, so the loop never inspects an error code:

import anyio
from vercel.connect import (
    AuthorizationDeniedError,
    AuthorizationExpiredError,
    AuthorizationPendingError,
    ConnectOptions,
)

authorization = await start_authorization(
    "linear/my-app", subject=subject, device_code=True
)
print(f"Enter {authorization.device_code} at {authorization.url}")

while True:
    try:
        token = await get_token(
            "linear/my-app", subject=subject, options=ConnectOptions(force_refresh=True)
        )
        break
    except AuthorizationPendingError:
        await anyio.sleep(5)
    except (AuthorizationDeniedError, AuthorizationExpiredError):
        raise  # terminal: nothing to wait for

force_refresh=True is what makes the poll reach the server; without it a cached credential would be returned. slow_down is reported as AuthorizationPendingError too, so a fixed interval stays correct.

Inbound triggers

A connector with triggers enabled forwards provider webhooks to your project with a Vercel OIDC token attached, so you verify one thing instead of a different signature scheme per provider:

from vercel.connect import verify_connect_webhook

claims = await verify_connect_webhook(request.headers)

Verification pins the issuer to Vercel's OIDC service, accepting both https://oidc.vercel.com and the team-scoped https://oidc.vercel.com/<team>, allows only RS256, and fails closed when the expected project and environment cannot be resolved. It accepts any valid Vercel OIDC token for this project and environment; it is not pinned to a specific connector or deployment.

Configuration

To configure advanced options, use a session context manager, and pass ConnectServiceOptions:

from vercel.api import session
from vercel.connect import ConnectAppTokenSubject, ConnectServiceOptions, get_token

async with session(
    service_options=[ConnectServiceOptions(base_url="https://staging.example.com")]
):
    token = await get_token("github/my-app", subject=ConnectAppTokenSubject())

Local development

On Vercel the OIDC token is injected automatically. Locally:

vercel link
vercel env pull    # writes VERCEL_OIDC_TOKEN into .env.local

The connector must be attached to your project and enabled for the target environment, or every call fails.

Metadata

Release files for vercel-connect-bundle 0.2.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 vercel-connect-bundle 0.2.0
File Size Uploaded Provenance Actions
vercel_connect_bundle-0.2.0.tar.gz 32.1 kB Without provenance Details for vercel_connect_bundle-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vercel-connect-bundle 0.2.0
File Interpreter ABI Platform Actions
vercel_connect_bundle-0.2.0-py3-none-any.whl Python 3 none any Details for vercel_connect_bundle-0.2.0-py3-none-any.whl

Total release size: 74.2 kB

Release files / vercel_connect_bundle-0.2.0.tar.gz

Download URL vercel_connect_bundle-0.2.0.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e8d42b1c9e9c61a1ec584ac54881d0f09369f4b0f7d2e77d2bf1df95bfabd487
BLAKE2b-256 checksum
How to use checksums
fd87dd593d20bd9d5b243a6dfacc150a90ec74047fa096ae5bdc4a117e32f03b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / vercel_connect_bundle-0.2.0-py3-none-any.whl

Download URL vercel_connect_bundle-0.2.0-py3-none-any.whl
Size 42.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78eb8e9140b4905b8b0aa62600dbc6044bb7e24fe8f14d9a12a6814d18464141
BLAKE2b-256 checksum
How to use checksums
95acfd9c4560752a875098d71591fd25f1da5a527072e9206148252623e90e33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for vercel-connect-bundle 0.2.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