Skip to content

Type the client token's signed token as always present - #69

Merged
AdirAmsalem merged 1 commit into
mainfrom
client-token-required
Sep 15, 2026
Merged

AdirAmsalem merged 1 commit into
mainfrom
client-token-required

Conversation

@AdirAmsalem

@AdirAmsalem AdirAmsalem commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Description

tokens.create() now types the signed token as always present instead of str | None. api_key stays as the opaque form for calls other than realtime and file uploads.

Changes

  • CreateTokenResponse.token is str. A response without it raises TokenCreateError instead of returning None.
  • Docstrings and the create_token example point frontends at token.

Merge after api-platform#822 is deployed; before that, a mint whose signing failed would raise here instead of returning the opaque key.

token = await client.tokens.create()
return {"token": token.token, "expiresAt": token.expires_at}  # what your frontend uses

Note

Medium Risk
This is a breaking typing/behavior change for integrators who branched on token is None, and mint calls can fail hard if deployed before the platform always returns a signed token.

Overview
tokens.create() now treats the signed JWT as mandatory, matching the platform contract after api-platform#822.

CreateTokenResponse.token is typed as str (not str | None). If a successful HTTP response omits token, the client raises TokenCreateError instead of returning None. Docstrings clarify that token is what browsers should use for realtime and uploads, while api_key remains the opaque ek_... credential for other calls.

The example and tests expect a JWT in every success payload, and a new test covers the missing-token error path.

Reviewed by Cursor Bugbot for commit cecc889. Bugbot is set up for automated code reviews on this repo. Configure here.

The platform now guarantees `token` on POST /v1/client/tokens (a signing
failure fails the mint), so drop the Optional and raise TokenCreateError if
a response ever lacks it instead of handing callers None to branch on. Docs
point frontends at `token`; `api_key` stays the opaque form for calls other
than realtime and file uploads.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cecc889. Configure here.

Comment thread decart/tokens/client.py
@AdirAmsalem
AdirAmsalem merged commit a109b24 into main Sep 15, 2026
9 checks passed
@AdirAmsalem
AdirAmsalem deleted the client-token-required branch September 15, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant