Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Check if refresh_token is None (#2025)

Kyle-Dinhf6e47d859d26
diff --git a/src/fastmcp/server/auth/oauth_proxy.py b/src/fastmcp/server/auth/oauth_proxy.py
index 89b9c63a5..998aa05a6 100644
--- a/src/fastmcp/server/auth/oauth_proxy.py
+++ b/src/fastmcp/server/auth/oauth_proxy.py
@@ -769,8 +769,7 @@ class OAuthProxy(OAuthProvider):
)
# Handle refresh token rotation if new one provided
- if "refresh_token" in token_response:
- new_refresh_token = token_response["refresh_token"]
+ if new_refresh_token := token_response.get("refresh_token"):
if new_refresh_token != refresh_token.token:
# Remove old refresh token
self._refresh_tokens.pop(refresh_token.token, None)