fastmcp/tests/server/auth/oauth_proxy
Jeremiah Lowin 52feff6878
Transparently refresh upstream token in OAuthProxy.load_access_token() (#3584)
* Transparently refresh upstream token in OAuthProxy.load_access_token()

When upstream token validation fails during load_access_token, attempt
to refresh using the stored refresh token before returning None. This
prevents premature 401s that force clients into expensive full re-auth
flows when the upstream token expires.

Co-authored-by: Claude <noreply@anthropic.com>

* Gate transparent refresh on token expiry, add advisory lock

Only attempt upstream refresh when the token is actually expired, not
on any validation failure (scope mismatch, revocation, etc.). Add
per-token advisory lock to prevent concurrent async tasks from racing
to refresh the same upstream token.

* Re-check expiry inside lock, reload from storage after refresh failure

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-22 10:43:44 -04:00
..
__init__.py Consolidate test fixtures and refactor large test files (#2941) 2026-01-19 15:18:35 -05:00
conftest.py Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_authorization.py Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_client_registration.py Consolidate test fixtures and refactor large test files (#2941) 2026-01-19 15:18:35 -05:00
test_config.py Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_e2e.py Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_oauth_proxy.py feat: make upstream_client_secret optional in OAuthProxy (#3486) 2026-03-15 11:14:56 -04:00
test_tokens.py Transparently refresh upstream token in OAuthProxy.load_access_token() (#3584) 2026-03-22 10:43:44 -04:00
test_ui.py Escape client_id in OAuth consent details (#3418) 2026-03-06 17:33:12 -05:00