Compare redirect URIs as strings 8000 #989
Open
+1
−1
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.
Motivation and Context
When testing the simple auth example server, I encountered 400 status codes from
POST /token
becauseTokenHandler.handle
was evaluatingtoken_request.redirect_uri != authorize_request_redirect_uri
asTrue
.This occurred because
token_request.redirect_uri
was of typeAnyUrl
, whileauthorize_request_redirect_uri
wasAnyHttpUrl
, and comparing these two different Pydantic types always returnsFalse
- even if the underlying URLs are the same.(Example:
AnyUrl("http://google.com") == AnyHttpUrl("http://google.com")
isFalse
.)I believe the example auth server worked before #895 changed some
AnyHttpUrl
s toAnyUrl
s in the validation code, but the example server was not updated.How Has This Been Tested?
Tested using Claude Code as the MCP client to connect to the example server:
claude mcp add --transport sse github http://localhost:8000/sse
The auth flow succeeded only after applying this patch.
Breaking Changes
None.
Types of changes
Checklist
Additional context
We could also update the example server to declare the redirect uri as
AnyHttpUrl
, but I think comparing the URIs as strings would make the validation less brittle.