OAuth Server Example
This example shows how to configure an MCP server with OAuth authentication.
Overviewβ
OAuth authentication is used for remote servers that require secure access. Radium handles token acquisition, storage, and refresh automatically.
Basic OAuth Configurationβ
[[servers]]
name = "oauth-server"
transport = "http"
url = "https://api.example.com/mcp"
auth = {
auth_type = "oauth",
params = {
token_url = "https://api.example.com/oauth/token",
client_id = "your-client-id",
client_secret = "your-client-secret"
}
}
OAuth Flowβ
- Initial Setup: Configure OAuth parameters in server config
- Token Acquisition: First token may need to be obtained manually (see OAuth Setup Guide)
- Token Storage: Tokens stored in
~/.radium/mcp_tokens/{server-name}.json - Automatic Refresh: Tokens are refreshed automatically when expired
Provider Examplesβ
GitHub OAuthβ
[[servers]]
name = "github-mcp"
transport = "http"
url = "https://api.github.com/mcp"
auth = {
auth_type = "oauth",
params = {
token_url = "https://github.com/login/oauth/access_token",
client_id = "your-github-client-id",
client_secret = "your-github-client-secret"
}
}
Google OAuthβ
[[servers]]
name = "google-mcp"
transport = "http"
url = "https://api.google.com/mcp"
auth = {
auth_type = "oauth",
params = {
token_url = "https://oauth2.googleapis.com/token",
client_id = "your-google-client-id",
client_secret = "your-google-client-secret"
}
}
Custom OAuth Providerβ
[[servers]]
name = "custom-api"
transport = "http"
url = "https://api.custom.com/mcp"
auth = {
auth_type = "oauth",
params = {
token_url = "https://api.custom.com/oauth/token",
client_id = "your-client-id",
client_secret = "your-client-secret",
scope = "read write" # Optional: specify scopes
}
}
Token Managementβ
Check Token Statusβ
rad mcp auth status
Token Storage Locationβ
Tokens are stored in: ~/.radium/mcp_tokens/{server-name}.json
Token File Formatβ
{
"access_token": "eyJhbGc...",
"token_type": "Bearer",
"refresh_token": "def502...",
"expires_at": 1234567890,
"scope": "read write"
}
Token Permissionsβ
Token files have restricted permissions (0600) on Unix systems:
- Owner: read/write
- Group: no access
- Others: no access
Troubleshootingβ
Token Not Foundβ
Problem: "No token found for server"
Solution:
- Check token file exists:
~/.radium/mcp_tokens/{server-name}.json - Verify server name matches config
- Initial token may need manual acquisition
- Check token file permissions
Token Expiredβ
Problem: "OAuth token expired"
Solution:
- Tokens should auto-refresh, but check:
rad mcp auth status - Verify
refresh_tokenis present in token file - Check
token_urlis correct - Verify client credentials are valid
Refresh Token Missingβ
Problem: "No refresh token available"
Solution:
- Some providers don't return refresh tokens
- May need to re-authenticate manually
- Check provider documentation for refresh token requirements
- Verify OAuth flow includes refresh token grant
Invalid Credentialsβ
Problem: "Authentication error: invalid client"
Solution:
- Verify
client_idis correct - Verify
client_secretis correct - Check credentials haven't been revoked
- Ensure OAuth app is properly configured with provider
Security Best Practicesβ
- Secure Storage: Tokens stored with restricted permissions (0600)
- No Version Control: Never commit tokens or credentials
- Credential Rotation: Rotate credentials periodically
- HTTPS Only: Always use HTTPS for token endpoints
- Scope Limitation: Request only necessary OAuth scopes
Advanced Configurationβ
Custom Token Endpointβ
Some providers use different token endpoint formats:
auth = {
auth_type = "oauth",
params = {
token_url = "https://api.example.com/v2/oauth/token",
client_id = "client-id",
client_secret = "client-secret",
grant_type = "refresh_token" # Some providers require explicit grant type
}
}
Token Refresh Behaviorβ
Tokens are automatically refreshed when:
- Token is expired (based on
expires_at) - Server returns 401 Unauthorized
- Before connection if token is already expired
Related Documentationβ
- OAuth Setup Guide - Detailed OAuth setup instructions
- Configuration Guide - General configuration reference
- Troubleshooting - Common OAuth issues
- User Guide - Getting started guide