Add created/expires fields to ApiCredentials with expiry check#62
Merged
Michel Edkrantz (MichelEdkrantz) merged 2 commits intomasterfrom Feb 24, 2026
Merged
Add created/expires fields to ApiCredentials with expiry check#62Michel Edkrantz (MichelEdkrantz) merged 2 commits intomasterfrom
Michel Edkrantz (MichelEdkrantz) merged 2 commits intomasterfrom
Conversation
ApiCredentials now carries optional created and expires fields as timezone-aware datetimes, parsed from the ISO 8601 strings in the credentials JSON (including Z suffix and nanosecond precision). Expiry is checked when an auth session is constructed (_check_expiry called after _resolve_credentials in RequestsAuthSession and HttpxAuthAsyncClient), so loading/storing credentials never fails due to expiry — only actually using them does. Keyring storage serialises the datetime fields back to ISO strings via .isoformat(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update test_base_client_sync.py to patch _resolve_credentials (renamed from resolve_credentials) and return ApiCredentials instead of tuples. Exclude generated _version.py from ruff. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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
createdandexpiresfields toApiCredentialsas timezone-awaredatetimeobjects, parsed from ISO 8601 strings in the credentials JSON (handlesZsuffix and nanosecond precision)RequestsAuthSession,HttpxAuthAsyncClient) via_check_expiry, so loading/storing credentials never fails due to expiry — only actually using them does.isoformat()_resolve_credentialsfunction returning the fullApiCredentialsobject;resolve_credentialsdelegates to it for backwards compatibilityTest plan
test_parse_stores_created_and_expires— fields parsed todatetimecorrectlytest_parse_does_not_check_expiry— expired credentials parse without errortest_parse_malformed_expires_returns_none— unparseable date becomesNoneTestCheckExpiry— expired raisesValueError, future/missing does notuv run pytest)🤖 Generated with Claude Code