feat(auth): add set_token and document push/pull token distribution#661
Conversation
Co-Authored-By: lino <lino@rapidata.ai>
ReviewOverall this is a clean, well-scoped follow-up. 1. Doc example references an undefined variable ( ```python 3. Renew — inject a newer token into a running client at any time;it is used from the next request on.worker.set_token(fresh_token)
2. No validation of the token shape in ```python The docstring (and the docs page) are explicit that the caller must pass the complete token object with an absolute 3. Test coverage No tests exercise Nothing blocking — the core change (a straightforward attribute swap wrapped in the same guard pattern as |
|
Review Overview Code quality / conventions
Potential issues
Minor
Verification Overall: solid, well-scoped change with good docs. The main actionable suggestion is #1 (fail fast on a missing |
Why
Follow-up to #655. Review feedback: the "Writing the file yourself" docs section just re-implemented the same file pattern as
maintain_token_file. It should instead teach the underlying primitives — how to get a token out of one client and how to ingest it into another — so customers can build any push/pull distribution (Redis, RPC, secret manager, …) instead of being funneled through a file.There was also an API gap blocking that: you could export a token (
get_token()) and bootstrap a client from one (token=), but there was no way to inject a fresh token into a running client — once its token expired you had to reconstruct it, which re-fires the init-time side calls the whole feature exists to avoid.What
RapidataClient.set_token(token)— the counterpart toget_token(): replace the token a live client authenticates with, effective from the next request. Also revives a client whose token already expired. Added onRESTClientObject(bothrest.pyandrest.mustache).expires_at; atomic writes if the transport is a file).Verification
set_tokenswap on a live client, expired client revived viaset_tokenwithout reconstructionmkdocs buildclean🔗 Session: https://session-43887903.poseidon.rapidata.internal/
🤖 Generated with Claude Code