Skip to content

Commit 184aafc

Browse files
fix: update remaining token storage implementations
1 parent 07af424 commit 184aafc

6 files changed

Lines changed: 11 additions & 11 deletions

File tree

docs_src/identity_assertion/tutorial001.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ def __init__(self) -> None:
2020
async def get_tokens(self) -> OAuthToken | None:
2121
return self.tokens
2222

23-
async def set_tokens(self, tokens: OAuthToken) -> None:
23+
async def set_tokens(self, tokens: OAuthToken | None) -> None:
2424
self.tokens = tokens
2525

2626
async def get_client_info(self) -> OAuthClientInformationFull | None:
2727
return self.client_info
2828

29-
async def set_client_info(self, client_info: OAuthClientInformationFull) -> None:
29+
async def set_client_info(self, client_info: OAuthClientInformationFull | None) -> None:
3030
self.client_info = client_info
3131

3232

examples/clients/simple-auth-client/mcp_simple_auth_client/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def __init__(self):
3737
async def get_tokens(self) -> OAuthToken | None:
3838
return self._tokens
3939

40-
async def set_tokens(self, tokens: OAuthToken) -> None:
40+
async def set_tokens(self, tokens: OAuthToken | None) -> None:
4141
self._tokens = tokens
4242

4343
async def get_client_info(self) -> OAuthClientInformationFull | None:
4444
return self._client_info
4545

46-
async def set_client_info(self, client_info: OAuthClientInformationFull) -> None:
46+
async def set_client_info(self, client_info: OAuthClientInformationFull | None) -> None:
4747
self._client_info = client_info
4848

4949

examples/snippets/clients/identity_assertion_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ def __init__(self) -> None:
3434
async def get_tokens(self) -> OAuthToken | None:
3535
return self.tokens
3636

37-
async def set_tokens(self, tokens: OAuthToken) -> None:
37+
async def set_tokens(self, tokens: OAuthToken | None) -> None:
3838
self.tokens = tokens
3939

4040
async def get_client_info(self) -> OAuthClientInformationFull | None:
4141
return self.client_info
4242

43-
async def set_client_info(self, client_info: OAuthClientInformationFull) -> None:
43+
async def set_client_info(self, client_info: OAuthClientInformationFull | None) -> None:
4444
self.client_info = client_info
4545

4646

examples/snippets/clients/oauth_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ async def get_tokens(self) -> OAuthToken | None:
2929
"""Get stored tokens."""
3030
return self.tokens
3131

32-
async def set_tokens(self, tokens: OAuthToken) -> None:
32+
async def set_tokens(self, tokens: OAuthToken | None) -> None:
3333
"""Store tokens."""
3434
self.tokens = tokens
3535

3636
async def get_client_info(self) -> OAuthClientInformationFull | None:
3737
"""Get stored client information."""
3838
return self.client_info
3939

40-
async def set_client_info(self, client_info: OAuthClientInformationFull) -> None:
40+
async def set_client_info(self, client_info: OAuthClientInformationFull | None) -> None:
4141
"""Store client information."""
4242
self.client_info = client_info
4343

examples/stories/_shared/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ class InMemoryTokenStorage:
3838
async def get_tokens(self) -> OAuthToken | None:
3939
return self.tokens
4040

41-
async def set_tokens(self, tokens: OAuthToken) -> None:
41+
async def set_tokens(self, tokens: OAuthToken | None) -> None:
4242
self.tokens = tokens
4343

4444
async def get_client_info(self) -> OAuthClientInformationFull | None:
4545
return self.client_info
4646

47-
async def set_client_info(self, client_info: OAuthClientInformationFull) -> None:
47+
async def set_client_info(self, client_info: OAuthClientInformationFull | None) -> None:
4848
self.client_info = client_info
4949

5050

src/mcp/client/auth/oauth2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _is_expired_client_secret(client_info: OAuthClientInformationFull) -> bool:
119119
def _is_invalid_client_response(body: bytes) -> bool:
120120
"""Identify RFC 6749 ``invalid_client`` responses independent of HTTP status."""
121121
try:
122-
payload = json.loads(body)
122+
payload: Any = json.loads(body)
123123
except (json.JSONDecodeError, UnicodeDecodeError):
124124
return False
125125
return isinstance(payload, dict) and payload.get("error") == "invalid_client"

0 commit comments

Comments
 (0)