Add --refresh-before flag to databricks auth token#4699
Open
anthonyivn2 wants to merge 1 commit intodatabricks:mainfrom
Open
Add --refresh-before flag to databricks auth token#4699anthonyivn2 wants to merge 1 commit intodatabricks:mainfrom
--refresh-before flag to databricks auth token#4699anthonyivn2 wants to merge 1 commit intodatabricks:mainfrom
Conversation
Users who use `databricks auth token` as an API key helper (e.g., for Claude Code) get expired tokens because the oauth2 library only refreshes within ~10 seconds of expiry. The new `--refresh-before` flag (e.g., `--refresh-before 5m`) refreshes the token if it expires within the given window. Depends on: databricks/databricks-sdk-go#1532 Resolves databricks#4564
d889a33 to
5f4bc44
Compare
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
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
--refresh-beforeflag todatabricks auth token(e.g.,--refresh-before 5m) that refreshes the token if it expires within the given durationdatabricks auth tokenas an API key helper (e.g., for Claude Code) get expired tokens because oauth2's default ~10-second expiry window is too shortResolves #4564
Depends on SDK PR: databricks/databricks-sdk-go#1532
Changes
cmd/auth/token.go: Added--refresh-beforeflag,refreshBeforefield inloadTokenArgs, wiredu2m.WithExpiryDeltacmd/auth/token_test.go: Added 3 test cases (forces refresh, skips refresh, zero preserves default)Test plan
refreshBeforeforces refresh when token expires within window (2h delta, 1h token)refreshBeforeskips refresh when token has enough time (5m delta, 1h token)refreshBefore: 0preserves default behaviorTestToken_loadTokentests pass (31/31)replacedirective after SDK release and verify CI passes