| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
When the auth server lives under a non-root path (e.g. /oauth2/api/v1/token), the eager refresh at the top of async_auth_flow used the fallback urljoin(get_authorization_base_url(server_url), '/token') which strips the path, hitting the wrong endpoint. Fix: only attempt the eager refresh when oauth_metadata is already populated (i.e. we know the real token_endpoint). Without metadata, let the request proceed with the stale token, receive a 401, and run full PRM/ASM discovery before retrying — which resolves the correct token endpoint. Includes regression test: test_auth_flow_skips_eager_refresh_when_metadata_missing Fixes modelcontextprotocol#3240
|
Hi team — friendly ping on this PR 🙂 CI is fully green (29/29 checks pass) and Cubic AI reviewer found no issues. This fixes the OAuth token refresh hitting the wrong endpoint when the auth server lives under a non-root path (issue #3240). Happy to address any feedback! |
Sorry, something went wrong.
|
Thanks for the PR. We're tracking this fix in #3263 instead, so I'm closing this one. Feel free to reopen if this is still relevant. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Problem
When the authorization server lives under a non-root path (e.g. https://host/oauth2/api/v1/token), the eager token refresh at the top of async_auth_flow hits the wrong endpoint.
Root cause: _refresh_token falls back to urljoin(get_authorization_base_url(server_url), "/token") when oauth_metadata is None. get_authorization_base_url strips the path, so a server at /oauth2/api/v1/token gets https://host/token instead.
This happens because the eager refresh runs before any PRM/ASM metadata discovery — so oauth_metadata is always None on a restart with cached-but-expired tokens.
Fix
Add and self.context.oauth_metadata is not None to the eager refresh guard. When metadata is missing:
This is correct because:
Fixes #3240