@@ -189,19 +189,14 @@ async def exchange_refresh_token(
189189 refresh_token = new_refresh_token ,
190190 )
191191
192- async def verify_access_token (self , token : str ) -> AuthInfo :
193- # Check if token exists
194- if token not in self .tokens :
195- raise InvalidTokenError ("Invalid access token" )
196-
197- # Get token info
198- token_info = self .tokens [token ]
192+ async def load_access_token (self , token : str ) -> AuthInfo | None :
193+ token_info = self .tokens .get (token )
199194
200195 # Check if token is expired
201- if token_info .expires_at < int (time .time ()):
202- raise InvalidTokenError ("Access token has expired" )
196+ # if token_info.expires_at < int(time.time()):
197+ # raise InvalidTokenError("Access token has expired")
203198
204- return AuthInfo (
199+ return token_info and AuthInfo (
205200 token = token ,
206201 client_id = token_info .client_id ,
207202 scopes = token_info .scopes ,
@@ -852,7 +847,8 @@ async def test_authorization_get(
852847 refresh_token = token_response ["refresh_token" ]
853848
854849 # Create a test client with the token
855- auth_info = await mock_oauth_provider .verify_access_token (access_token )
850+ auth_info = await mock_oauth_provider .load_access_token (access_token )
851+ assert auth_info
856852 assert auth_info .client_id == client_info ["client_id" ]
857853 assert "read" in auth_info .scopes
858854 assert "write" in auth_info .scopes
@@ -888,10 +884,9 @@ async def test_authorization_get(
888884 assert response .status_code == 200
889885
890886 # Verify that the token was revoked
891- with pytest .raises (InvalidTokenError ):
892- await mock_oauth_provider .verify_access_token (
893- new_token_response ["access_token" ]
894- )
887+ assert await mock_oauth_provider .load_access_token (
888+ new_token_response ["access_token" ]
889+ ) is None
895890
896891
897892class TestFastMCPWithAuth :
0 commit comments