Extract reusable OAuth authorization redirect builder#2856
Draft
maxpetrusenkoagent wants to merge 1 commit into
Draft
Conversation
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
Fixes #1743.
Extracts the reusable OAuth authorization redirect step from
OAuthClientProviderinto a public helper for proxy/server-side use cases:OAuthAuthorizationRedirect, a resumable authorization redirect result containing the authorization URL, OAuth state, and PKCE verifierbuild_authorization_redirect(...)so callers can build and persist the browser redirect step without needingredirect_handler/callback_handlerOAuthClientProviderbehavior routed through the new helperrepr(...)Verification
uv run --frozen pytest tests/client/test_auth.py tests/interaction/auth/test_flow.py -quv run --frozen coverage erase && uv run --frozen coverage run -m pytest tests/client/test_auth.py tests/interaction/auth/test_flow.py && uv run --frozen coverage combine && uv run --frozen coverage report --include='src/mcp/client/auth/oauth2.py,src/mcp/client/auth/__init__.py' --fail-under=0 && UV_FROZEN=1 uv run --frozen strict-no-coveruv run --frozen ruff format --check src/mcp/client/auth/oauth2.py src/mcp/client/auth/__init__.py tests/client/test_auth.pyuv run --frozen ruff check src/mcp/client/auth/oauth2.py src/mcp/client/auth/__init__.py tests/client/test_auth.pyuv run --frozen pyright src/mcp/client/auth/oauth2.py src/mcp/client/auth/__init__.py tests/client/test_auth.py./scripts/test→ 1786 passed, 5 skipped, 1 xfailed, 100.00% coverage, strict-no-cover cleanReview
Local autoreview found no blocking issues. It suggested preserving existing authorization endpoint query parameters and hiding the PKCE verifier in repr; both are included and covered by regression tests.