Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667---title: discordsidebarTitle: discord---
# `fastmcp.server.auth.providers.discord`
Discord OAuth provider for FastMCP.
This module provides a complete Discord OAuth integration that's ready to usewith just a client ID and client secret. It handles all the complexity ofDiscord's OAuth flow, token validation, and user management.
Example: ```python from fastmcp import FastMCP from fastmcp.server.auth.providers.discord import DiscordProvider
# Simple Discord OAuth protection auth = DiscordProvider( client_id="your-discord-client-id", client_secret="your-discord-client-secret" )
mcp = FastMCP("My Protected Server", auth=auth) ```
## Classes
### `DiscordTokenVerifier` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/auth/providers/discord.py#L42" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Token verifier for Discord OAuth tokens.
Discord OAuth tokens are opaque (not JWTs), so we verify themby calling Discord's tokeninfo API to check if they're valid and get user info.
**Methods:**
#### `verify_token` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/auth/providers/discord.py#L72" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonverify_token(self, token: str) -> AccessToken | None```
Verify Discord OAuth token by calling Discord's tokeninfo API.
### `DiscordProvider` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/auth/providers/discord.py#L165" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Complete Discord OAuth provider for FastMCP.
This provider makes it trivial to add Discord OAuth protection to anyFastMCP server. Just provide your Discord OAuth app credentials anda base URL, and you're ready to go.
Features:- Transparent OAuth proxy to Discord- Automatic token validation via Discord's API- User information extraction from Discord APIs- Minimal configuration required