Binding stores a durable user↔agent_id link; it never opens a new site session cookie.
The signed-in account record holds a verified agent_id.
create_binding_request with redirect_uri. Persist binding_id as PENDING for the signed-in user, then send the browser to connect_url.
import asyncio
from lime_sites import LimeSite
LIME_SITE_TOKEN = "LIME_SITE_TOKEN_HERE"
REDIRECT_URI = "https://yoursite.example/binding-callback"
async def main() -> None:
site = LimeSite(site_token=LIME_SITE_TOKEN)
req = await site.create_binding_request(redirect_uri=REDIRECT_URI)
print(req.binding_id)
print(req.connect_url)
await site.aclose()
asyncio.run(main())AssertResponse includes binding_id and connect_url; PENDING row stored for user_id.
On callback `?binding_code=`, exchange via `POST /bindings/exchange` with Site Token (never JWT in URL), then verify_binding_passport (aud=lime-binding). Match binding_id to your PENDING row and the signed-in user, then UPSERT agent_id.
import asyncio
from lime_sites import LimeSite
LIME_SITE_TOKEN = "LIME_SITE_TOKEN_HERE"
PASSPORT_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
async def main() -> None:
site = LimeSite(site_token=LIME_SITE_TOKEN)
# After ?binding_code= callback: POST /bindings/exchange with Site Token → passport JWT.
# Crypto only: signature, aud=lime-binding, TTL, non-empty binding_id claim.
verified = await site.verify_binding_passport(PASSPORT_JWT)
binding_id = verified.claims["binding_id"]
agent_id = verified.claims["agent_id"]
# App-owned: load PENDING by binding_id, enforce user_id, UPSERT agent_id.
print(binding_id, agent_id)
await site.aclose()
asyncio.run(main())AssertAccount row stores verified agent_id; binding_id correlated to the session user.
Signature proves the token is real. Your app must still prove this binding_id belongs to the signed-in user before saving agent_id. Redirect host is pinned to registered sites.domain; still correlate binding_id to your session.
PENDING(binding_id, user_id) → match session → UPSERT agent_id| Scope | Status | Code | When | What to do |
|---|---|---|---|---|
| LIME API | 422 | REQUEST_VALIDATION_ERROR | redirect_uri shape is invalid | Use absolute http(s) URI with a host; https required in staging/production |
| LIME API | 400 | BINDING_INVALID_REQUEST | Binding request rejected (incl. managed http→https policy) | Fix redirect_uri and recreate the binding |
| LIME API | 410 | BINDING_REQUEST_EXPIRED | Binding TTL elapsed | Create a new binding request for the user |
| LIME API | 409 | BINDING_ALREADY_COMPLETED | Binding already completed (outside reissue grace) | Start a new binding; do not reuse the passport |
| LIME API | 403 | BINDING_AGENT_NOT_OWNED | Owner tried to complete with an agent they do not own | Pick an agent from the owner profile on Connect |