MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / OAuthToken

Class OAuthToken

src/mcp/shared/auth.py:6–22  ·  view source on GitHub ↗

See https://datatracker.ietf.org/doc/html/rfc6749#section-5.1

Source from the content-addressed store, hash-verified

4
5
6class OAuthToken(BaseModel):
7 """See https://datatracker.ietf.org/doc/html/rfc6749#section-5.1"""
8
9 access_token: str
10 token_type: Literal["Bearer"] = "Bearer"
11 expires_in: int | None = None
12 scope: str | None = None
13 refresh_token: str | None = None
14
15 @field_validator("token_type", mode="before")
16 @classmethod
17 def normalize_token_type(cls, v: str | None) -> str | None:
18 if isinstance(v, str):
19 # Bearer is title-cased in the spec, so we normalize it
20 # https://datatracker.ietf.org/doc/html/rfc6750#section-4
21 return v.title()
22 return v # pragma: no cover
23
24
25class AuthorizationCodeResult(BaseModel):

Calls

no outgoing calls