OAuth Token Store Protocol (store/base.py)

mcp-agent · src/mcp_agent/oauth/store/base.py · python · Apache-2.0
auth, database, security, lang:python, tag:protocol

Defines an abstract asynchronous protocol and key structures for persisting and retrieving OAuth tokens.

# Source: https://github.com/lastmile-ai/mcp-agent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Abstract token store definition."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Iterable, Protocol

from ..records import TokenRecord


@dataclass(frozen=True)
class TokenStoreKey:
    """Uniquely identifies a cached token."""

    user_key: str
    resource: str
    authorization_server: str | None
    scope_fingerprint: str


def scope_fingerprint(scopes: Iterable[str]) -> str:
    """Return a deterministic fingerprint for a scope list."""
    return " ".join(sorted({scope.strip() for scope in scopes if scope}))


class TokenStore(Pro

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key