Skip to main content

packages/auth — recreator auth

Device-flow sign-in for the CLI, and the one file that holds the MCP token.

recreator auth login → device code → browser: email + OTP → approve → rcr_ token at ~/.recreator/token

Why the device flow

OAuth 2.0 Device Authorization Grant (RFC 8628), the same model as gh auth login. Chosen over a localhost-callback server because it needs no free port and no reachable loopback — so it works over SSH and inside a container, which is where an agent toolkit actually runs.

The two hops

/device/token returns a Better Auth session token, not an API key. Sessions expire and are cookie-cache bound; the MCP server authenticates with an @better-auth/api-key value. So login is two requests:

  1. POST /api/auth/device/code → device_code, user_code, verification_uri
  2. poll POST /api/auth/device/token → session token on approval
  3. POST /api/auth/api-key/create with that session → the raw rcr_ key, returned exactly once (the server stores only a SHA-256 digest)

Only the rcr_ key is written to disk. The session token is discarded.

Polling rules that are not optional

Encoded in poll_for_token, and the reason that function takes an injectable sleep and monotonic:

  • Honour the server's interval (5s as configured).
  • slow_down adds 5s and keeps going — it is not a failure.
  • authorization_pending keeps going.
  • access_denied / expired_token stop with an actionable message.
  • Stop at expires_in. The deadline is checked before sleeping, so the loop never spends an interval to learn what it already knows.

The token file

~/.recreator/token, mode 0600, in a 0700 directory, created with the final mode rather than chmod-ed afterwards — an umask-widened file would be world-readable for the window in between.

Login refuses to overwrite an existing token without --force, matching the project's convention for destructive acts.

~/.recreator/ is shared with unrelated secrets (registry-token, env.sh, resend-api-key). This package reads and writes the token entry and nothing else. RECREATOR_TOKEN_FILE overrides the path, which is how tests stay off a real credential.

Client identity

client_id is recreator-cli, which must appear in the portal's DEVICE_CLIENT_IDS allowlist (apps/web/src/lib/auth.ts). The allowlist is load-bearing: without it the plugin accepts any client_id, and a device code could be minted under an attacker-chosen identity.

Layout

storage.py   the token file: permissions, overwrite refusal, masking
device.py    RFC 8628 protocol + the polling state machine. No I/O beyond HTTP.
session.py   session → rcr_ key exchange, and identity lookup for `status`
login.py     order of operations, printed output, exit codes

device.py talks to a Transport protocol, so the state machine is tested with a scripted transport and a fake clock — no network, no real sleeping.

Commands

recreator auth login                 # device flow, opens a browser
recreator auth login --no-browser    # print the URL instead (SSH, containers)
recreator auth login --force         # replace an existing token
recreator auth status                # masked token + portal validation
recreator auth status --offline      # skip the portal round trip
recreator auth logout                # delete the token

--base-url points any of these at a preview deployment instead of production.

Metadata

Release files for recreator-auth 0.1.4

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

Source distribution (sdist)

Source distribution for recreator-auth 0.1.4
File Size Uploaded Provenance Actions
recreator_auth-0.1.4.tar.gz 13.5 kB Without provenance Details for recreator_auth-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for recreator-auth 0.1.4
File Interpreter ABI Platform Actions
recreator_auth-0.1.4-py3-none-any.whl Python 3 none any Details for recreator_auth-0.1.4-py3-none-any.whl

Total release size: 26.7 kB

Release files / recreator_auth-0.1.4.tar.gz

Download URL recreator_auth-0.1.4.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dbad2c6f45c0c3ba739dbe5b91f22472f58f372cbf74364c3cbf2670cfb58576
BLAKE2b-256 checksum
How to use checksums
3cff2fa680272907b684bb97bbd289c4c30032253baf441c997477accdb8c363
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / recreator_auth-0.1.4-py3-none-any.whl

Download URL recreator_auth-0.1.4-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db870b8804d679680016bea11fe87129524277d2884408ebbb51db6f98af9d4c
BLAKE2b-256 checksum
How to use checksums
c5f6d18abf7151c7921ce8e4900cf631595f54dfb531270a642f4859f5048b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for recreator-auth 0.1.4

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