Skip to main content

fastmcp.server.auth.providers.in_memory

Classes

InMemoryOAuthProvider

An in-memory OAuth provider for testing purposes. It simulates the OAuth 2.1 flow locally without external calls. Methods:

get_client

register_client

authorize

Simulates user authorization and generates an authorization code. Returns a redirect URI with the code and state.

load_authorization_code

exchange_authorization_code

load_refresh_token

exchange_refresh_token

load_access_token

verify_token

Verify a bearer token and return access info if valid. This method implements the TokenVerifier protocol by delegating to our existing load_access_token method. Args:
  • token: The token string to validate
Returns:
  • AccessToken object if valid, None if invalid or expired

revoke_token

Revokes an access or refresh token and its counterpart.