refactor(sdk): hand OAuth token requests to Authlib 1.8.0 (0.3.1) - #16
Merged
Conversation
Authlib 1.8.0 (2026-08-30) ships httpx2 support, so PKCE challenge generation, the authorization URL, code exchange, and refresh now go through its OAuth2Client instead of hand-rolled request building. The point is to stop owning protocol code: Authlib maintains RFC 6749/7636 handling, we keep only what it lacks. What stays ours, deliberately: - DiscolikeAuth (httpx2.Auth): single 401 replay, cross-process credential reload (PropelAuth revokes the whole refresh family on a replayed refresh token, so two CLI processes must not both refresh), sync+async locks, and the API-key branch. Authlib's sync client has no lock and refreshes on expiry only. - Dynamic client registration and metadata discovery: Authlib has no RFC 7591 client (authlib/authlib#526, open since 2023). TokenClient/AsyncTokenClient override parse_response_token so error types, status codes, and token-redacted payloads are unchanged for callers. Refreshes use a dedicated token-endpoint client (30s timeout) rather than the SDK http_client, so proxies configured there no longer reach the token endpoint; noted in the changelog. Verified live against prod: login (reused DCR client), status, usage, proactive refresh with token rotation, and 401 replay. Also: README sign-up links to discolike.com/signup.
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.
Why
Authlib 1.8.0 (released 2026-08-30) supports httpx2, so the SDK no longer needs to own OAuth protocol code. PKCE, authorization URL, code exchange, and refresh now go through Authlib's
OAuth2Client/AsyncOAuth2Client.What stays in-house
DiscolikeAuth: 401 replay, cross-process credential reload (PropelAuth revokes the refresh family on replay), sync+async locks, API-key branch. Authlib's sync client has no lock and only refreshes on expiry.TokenClient/AsyncTokenClientoverrideparse_response_tokensoOAuthError.error,status_code, and token-redacted payloads are unchanged.Behavior notes
http_client; proxies/transports onhttp_client=don't reach the token endpoint. In CHANGELOG.expires_atis whole seconds (Authlib rounds), ≤1s conservative.authlib>=1.8.0(pullscryptography,joserfc).Verified against prod
auth login(reused stored DCR client),auth status,account usage, proactive refresh with rotation persisted, 401 replay with rotation.Also: README sign-up links →
discolike.com/signup.Greptile Summary
The PR delegates PKCE authorization, code exchange, and token refresh to Authlib 1.8.0 while retaining DiscoLike’s credential persistence, locking, cross-process reload, and 401 replay behavior.
Confidence Score: 5/5
The PR appears safe to merge with no concrete changed-code defect identified.
The Authlib integration preserves the established OAuth request shapes, credential rotation and persistence behavior, sync and async coordination, 401 replay, and SDK error payload contracts; the intentional dedicated-client transport change is documented.
Important Files Changed
Reviews (1): Last reviewed commit: "refactor(sdk): hand OAuth token requests..." | Re-trigger Greptile