Add WithExpiryDelta option to PersistentAuth#1532
Open
anthonyivn2 wants to merge 1 commit intodatabricks:mainfrom
Open
Add WithExpiryDelta option to PersistentAuth#1532anthonyivn2 wants to merge 1 commit intodatabricks:mainfrom
anthonyivn2 wants to merge 1 commit intodatabricks:mainfrom
Conversation
anthonyivn2
added a commit
to anthonyivn2/cli
that referenced
this pull request
Mar 11, 2026
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
5 tasks
…xpiry margin 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. This adds a configurable safety margin so the token is refreshed earlier when needed. - Add `expiryDelta` field and `WithExpiryDelta` option function - Add `tokenValid` method that uses the custom delta when set - Force-expire token copy before refresh so oauth2 TokenSource performs the actual refresh even when the token has time left by its standards
dd157c3 to
ae24be8
Compare
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
anthonyivn2
added a commit
to anthonyivn2/cli
that referenced
this pull request
Mar 11, 2026
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
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
WithExpiryDelta(d time.Duration)option toPersistentAuththat configures a custom token expiry safety margindremaining, triggering an early refreshdatabricks 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 databricks/cli#4564
Changes
credentials/u2m/persistent_auth.go: AddedexpiryDeltafield,WithExpiryDeltaoption,tokenValidmethod, and updatedToken()to use custom validity checkcredentials/u2m/persistent_auth_test.go: Added 8 tests covering all edge cases (delta triggers/skips refresh, zero delta, zero expiry, nil/empty tokens)Test plan
tokenValidwith various delta/expiry combinationsToken()verifying refresh is triggered/skipped correctlycredentials/u2m/passNO_CHANGELOG=true