Add automatic short-lived API token refresh (GL-1709)#446
Closed
timmarkhuff wants to merge 4 commits into
Closed
Conversation
Bootstrap tokens mint a cached working credential with daily background rotation, file-locked multi-process coordination, and temporary list-and-match name lookup until the by-snippet endpoint is live. Co-authored-by: Cursor <cursoragent@cursor.com>
Silence pylint on TokenManager, narrow Optional slot access for mypy, and reinstall the previous working token if a 401 remint fails mid-flight. Co-authored-by: Cursor <cursoragent@cursor.com>
Adding Groundlight.close for token-refresh lifecycle made the CLI crash on KeyError because close was not in _COMMAND_GROUPS. Also harden expires_at timezone comparisons. Co-authored-by: Cursor <cursoragent@cursor.com>
Prod does not expose /v1/api-tokens yet, which broke docs tests that construct Groundlight(). Keep using the bootstrap credential and skip auto-refresh until those endpoints exist. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GROUNDLIGHT_API_TOKENas a bootstrap credential: the client mints a short-lived working token, caches it on disk, and refreshes it daily in a background thread.Design notes
GROUNDLIGHT_TOKEN_DIR), keyed by the bootstrap token snippet.GET /v1/api-tokensand matchesraw_key_snippet._get_token_name_by_snippetis implemented but unused until zuuul#6579 is live; TODOs mark the switch-before-merge.Test plan
poetry run pytest test/unit/test_token_manager.py -v --noconftestGroundlight()against integ/prod; confirm a slot file is written andwhoamisucceeds with the minted token_lookup_token_nameto_get_token_name_by_snippetonce zuuul#6579 is deployed