Troubleshooting Guide
Common issues and solutions when using oauth-mcp-proxy.
Authentication Errors
"Authentication required: missing OAuth token"
Cause: Token not extracted from HTTP request
Solutions:
Check Authorization header present:
# Make sure you're sending the header
curl -H "Authorization: Bearer <token>" https://server.com/mcpVerify CreateHTTPContextFunc configured:
streamable := mcpserver.NewStreamableHTTPServer(
mcpServer,
mcpserver.WithHTTPContextFunc(oauth.CreateHTTPContextFunc()), // Required!
)Check header format:
✅ Authorization: Bearer eyJhbGc...
❌ Authorization: eyJhbGc... (missing "Bearer ")
❌ authorization: Bearer ... (lowercase - case-sensitive!)"Authentication failed: invalid token"
Cause: Token validation failed
Check:
Token not expired:
Issuer matches:
Audience matches:
Signature valid (HMAC):
Provider reachable (OIDC):
Debug:
Configuration Errors
"invalid config: provider is required"
Cause: Missing or empty Provider field
Solution:
"invalid config: JWTSecret is required for HMAC provider"
Cause: Using HMAC provider without JWTSecret
Solution:
"invalid config: Issuer is required for OIDC provider"
Cause: Using Okta/Google/Azure without Issuer
Solution:
"invalid config: proxy mode requires ClientID"
Cause: Mode is "proxy" but ClientID not provided
Solution:
Provider Errors
"Failed to initialize OIDC provider"
Cause: Cannot connect to OAuth provider's discovery endpoint
Check:
Issuer URL correct:
Network connectivity:
Firewall/proxy:
Check corporate firewall allows outbound HTTPS
Check proxy settings if behind corporate proxy
Debug:
Redirect URI Errors
"Invalid redirect URI" (Native Mode)
Cause: Client redirect is not localhost (security protection)
Fixed redirect mode only allows localhost:
Why: Prevents open redirect attacks in fixed redirect mode.
Solution: Use allowlist mode if you need non-localhost redirects:
"redirect_uri_mismatch" (Provider Error)
Cause: Redirect URI not configured in OAuth provider
Solutions:
Okta:
Go to Applications → Your App → General
Add to "Sign-in redirect URIs"
Must match exactly (including trailing slash if present)
Google:
Cloud Console → Credentials → OAuth 2.0 Client
Add to "Authorized redirect URIs"
Exact match required
Azure:
App registrations → Your App → Authentication
Add to "Redirect URIs"
Must match exactly
Token Caching Issues
Tokens Not Being Cached
Expected: Second request with same token should be faster (cache hit)
Check:
Cache logs:
Cache TTL: 5 minutes (hardcoded in v0.1.0)
Cache scope: Per Server instance
Debug:
Different Server instances = different caches
Token modified between requests = new cache entry
Token expired = cache miss
Metrics:
Runtime Errors
Panic: "invalid memory address or nil pointer dereference"
Cause: Usually missing logger in test code or direct handler creation
Solution:
"Token exchange failed"
Cause: OAuth provider rejected token exchange request
Check:
Authorization code valid:
Code must be unused (single-use only)
Code must not be expired (typically 10 minutes)
PKCE parameters match:
Redirect URI matches:
Client credentials valid:
Debug:
Check OAuth provider logs (Okta/Google/Azure admin consoles)
Look for specific error codes in provider response
Performance Issues
Slow Authentication
Expected latency:
Cache hit: <5ms
Cache miss (HMAC): <10ms
Cache miss (OIDC): <100ms (network call to provider)
If slower:
OIDC discovery slow:
First request does OIDC discovery (fetches
.well-known/openid-configuration)Cached after first request
Network latency to provider affects first request
JWKS fetch slow:
OIDC validator fetches public keys on initialization
Check network latency to OAuth provider
Solutions:
Warm up on server start (make a test validation call)
Check network connectivity to OAuth provider
Consider caching OIDC discovery (future enhancement)
Development vs Production
Works Locally, Fails in Production
Common causes:
HTTPS not configured:
Secrets not in environment:
Provider can't reach callback URL:
ServerURL must be publicly accessible
Firewall must allow inbound HTTPS
DNS must resolve correctly
Redirect URI mismatch:
Localhost works in dev, but production URL different
Update OAuth provider redirect URIs for production domain
Debugging Tips
Enable Verbose Logging
Check OAuth Metadata
Decode JWT Token
Test Token Manually
Still Having Issues?
Check logs: Look for ERROR and WARN level messages
Verify configuration: Review CONFIGURATION.md
Check provider setup: Review provider-specific guide in providers/
Security check: Review SECURITY.md
GitHub Issues: Search or create issue at github.com/tuannvm/oauth-mcp-proxy/issues
Common Patterns
Multiple OAuth Providers
Custom Token Claims
Currently, oauth-mcp-proxy extracts:
sub→ User.Subjectemail→ User.Emailpreferred_username→ User.Username (fallback to email or sub)
For custom claims, access the raw token:
Getting Help
📖 Documentation: docs/
💬 Discussions: GitHub Discussions (coming soon)
🐛 Bug Reports: GitHub Issues
🔒 Security: Email maintainer for confidential issues
Last updated
Was this helpful?