Choosing an Authentication Method
Poke supports four authentication patterns based on the MCP Authorization specification. The right choice depends on what you’re building:| Method | What You’re Building | User Experience | Implementation | Example |
|---|---|---|---|---|
| Remote OAuth with DCR | A brand new service (your own data, your own users) | One-time auth, automatic refresh | Use an identity provider (WorkOS, Auth0) | Bookmark Manager |
| OAuth Proxy | Connecting an existing API (WHOOP, GitHub, Strava, etc.) | One-time auth, automatic refresh | Proxy to the existing OAuth provider | WHOOP Integration |
| API Key | Simple auth for testing or developer tools | Paste key once | Validate bearer tokens | Weather API |
| No Auth | Public data with no user identity | Zero setup | No authentication needed | ISS Tracker |
Understanding the Two OAuth Patterns
Remote OAuth with DCR: Building Your Own Service Use this when you’re creating something new and you need user management. You control the data, and users are authenticating with your service.- What you’re building: A new integration where you store and manage user data
- How it works: Use an identity provider like WorkOS AuthKit to handle the OAuth server (they manage user accounts, tokens, sessions)
- Your responsibility: Build your tools and validate tokens from the IdP
- MCP clients: Can register automatically (Dynamic Client Registration)
- Example: See the Bookmark Manager for a complete implementation where users save personal bookmarks to your database
- What you’re building: An integration that wraps an existing API with existing OAuth
- How it works: Your MCP server acts as a bridge between Poke and the upstream OAuth provider
- Your responsibility: Create an OAuth app in the provider’s dashboard, configure FastMCP’s proxy, validate upstream tokens
- MCP clients: Connect through your server’s proxy (your server handles the DCR part)
- Example: See the WHOOP Integration where users authenticate with WHOOP and you fetch their health data
Simple rule: If you’re building something new from scratch, use Remote
OAuth with DCR. If you’re connecting an existing service that already has
OAuth, use OAuth Proxy.
OAuth 2.1 with PKCE
Both OAuth patterns use the same OAuth 2.1 + PKCE flow. The difference is in who manages authentication:- Remote OAuth with DCR: An identity provider (WorkOS, Auth0) handles authentication for your new service
- OAuth Proxy: You proxy through to an existing service’s OAuth provider (WHOOP, GitHub, etc.)
What Poke Does as a Client (Same for Both Patterns)
When a user connects your integration, Poke:- Discovers your OAuth config via the
.well-knownendpoint - Handles PKCE flow (generates
code_verifierandcode_challenge) - Redirects users to your authorization URL
- Exchanges authorization codes for tokens
- Stores tokens securely (encrypted at rest)
- Refreshes tokens automatically before expiration
- Includes tokens in every request via
Authorization: Bearerheader
Complete OAuth Flow
Key MCP requirements Poke implements:- RFC 9728 (Protected Resource Metadata) for authorization server discovery
- RFC 8414 (Authorization Server Metadata) for endpoint discovery
- RFC 7591 (Dynamic Client Registration) when your server supports it
- PKCE with S256 (mandatory per MCP spec) for authorization code protection
- Resource parameter (RFC 8707) to bind tokens to your specific server
FastMCP OAuth Implementations
FastMCP provides different OAuth implementations depending on what you’re building:For New Services: AuthKitProvider (Remote OAuth with DCR)
When building a new service from scratch, useAuthKitProvider to integrate with WorkOS AuthKit:
- JWT token validation via JWKS
- Protected resource metadata (
/.well-known/oauth-protected-resource) - Authorization server discovery
- User identity via token claims
For Existing Services: OAuthProxy
When wrapping an existing OAuth provider (WHOOP, GitHub, etc.), useOAuthProxy:
- Proxying OAuth flow to upstream provider
- PKCE between Poke and your server, and your server and upstream
- Token exchange with upstream provider
- Exposing MCP-compatible discovery endpoints
OAuth Discovery: What Poke Expects
When Poke connects to your server and receives a 401 response, it expects specific metadata endpoints:1. Protected Resource Metadata
Endpoint:GET /.well-known/oauth-protected-resource
Response:
2. Authorization Server Metadata
Endpoint:GET /.well-known/oauth-authorization-server
Response:
Token Validation
Your MCP server must validate access tokens on every request:- Verify token signature (if using JWT)
- Check expiration (
expclaim) - Validate audience (token issued for your server)
- Verify scopes (user authorized required permissions)
- Return 401 if any check fails
Token Refresh
Poke automatically refreshes tokens before expiration. Your authorization server must support refresh tokens: Request Poke makes:When Users Should See OAuth
OAuth prompts should appear:- First connection: User hasn’t authorized your integration yet
- Token expired: Refresh token is invalid/expired, requires reauthorization
- Scope changes: You request additional permissions
API Key Authentication
What You Build
An MCP server that accepts bearer tokens in theAuthorization header and validates them against your backend.
What Poke Does
When a user adds your integration with an API key:- User pastes API key in Poke’s connection form
- Poke tests connection by calling your server with
Authorization: Bearer <key> - If validation succeeds, integration is connected
- Every subsequent request includes the same header
Request Format
Validation Best Practices
Do:- Validate keys on every request
- Return 401 for invalid/expired keys
- Rate limit by API key
- Support key rotation (users can update keys in Poke)
- Accept keys in URL query parameters (security risk)
- Log API keys (store hashed versions)
- Return detailed error messages (prevents enumeration attacks)
When to Use API Keys
Good fit:- Developer/power user integrations
- Services with existing API key infrastructure
- Testing and development environments
- Read-only or low-risk operations
- Consumer-facing apps (OAuth is better UX)
- High-security requirements (keys don’t expire)
- Per-user data access (hard to manage at scale)
No Authentication
What You Build
An MCP server that returns data without checking authentication.What Poke Does
- User enters server URL
- Poke connects immediately (no auth prompt)
- Tools are available for all users
When to Use No Auth
Good fit:- Public APIs (weather, astronomy, public datasets)
- Read-only data that’s not sensitive
- Internal tools within trusted networks
- Testing and demos
- Rate limit by IP to prevent abuse
- Monitor usage patterns for anomalies
- Consider API keys if abuse occurs
- Document public endpoints clearly
Security Best Practices
For All Authentication Methods
- Use HTTPS everywhere (required by MCP spec for production)
- Validate all inputs before processing requests
- Rate limit requests to prevent abuse
- Log authentication failures for monitoring
- Rotate secrets regularly (OAuth secrets, API keys, encryption keys)
OAuth-Specific
- Implement PKCE (mandatory for public clients)
- Validate state parameter to prevent CSRF attacks
- Bind tokens to audience (verify tokens are for your server)
- Issue short-lived access tokens (15-60 minutes recommended)
- Rotate refresh tokens on each use
- Never pass through tokens to third-party APIs (see MCP Security Best Practices)
API Key-Specific
- Hash keys in database (don’t store plaintext)
- Use cryptographically secure random generation (e.g.,
secrets.token_urlsafe()) - Prefix keys with identifiable strings (e.g.,
sk_live_,sk_test_) - Implement key expiration if possible
- Allow users to revoke keys easily
No Auth-Specific
- Rate limit aggressively (per IP, per user agent)
- Cache responses to reduce load
- Monitor for scraping (unusual access patterns)
- Implement CORS properly if browser-based
- Document acceptable use clearly
Testing Authentication
OAuth Testing
Local development:- Deploy to HTTPS endpoint (OAuth requires secure redirects)
- Test full flow in Poke’s integration tester
- Verify token refresh works correctly
- Test error cases (denied access, expired tokens)
API Key Testing
No Auth Testing
How Authentication Interacts with Tool Lifecycle
Authentication happens before tool discovery: Key points:- Tools discovered once after successful authentication
- Auth credentials used for all subsequent tool calls
- Reconnection required if auth changes (new scopes, new key)
- Token refresh transparent to tool execution
Next Steps
Authentication Examples
Complete, runnable examples for all four auth patterns with deployment guides
Quick Start
Build your first integration (no auth) in 5 minutes
ISS Tracker
No auth example - real-time space station location
Weather API
API key example - validate user credentials
WHOOP Integration
OAuth Proxy example - wrap existing OAuth APIs
Bookmark Manager
Remote OAuth + DCR example - build new multi-user services
Tool Lifecycle
How auth interacts with tool discovery and caching
MCP Authorization Spec
Official MCP authorization specification