OAuth Flow
Detailed OAuth 2.0 authorization flow for Madgicx MCP.
OAuth Flow
This page describes the OAuth 2.0 authorization code flow with PKCE used by Madgicx MCP.
Flow Overview
Step 1: Client Initialization
The AI client generates PKCE parameters:
Step 2: Authorization Request
Client redirects user to the authorization endpoint:
Step 3: User Authentication
User logs in to Madgicx and selects their team:
- Enter Madgicx credentials (or SSO)
- Select team from dropdown
- Review requested permissions
- Click "Authorize"
Step 4: Authorization Code
After approval, user is redirected back with an authorization code:
Step 5: Token Exchange
Client exchanges the code for tokens:
Step 6: Token Response
Server returns access and refresh tokens:
Team Selection
During authorization, users select which Madgicx team to connect. The selected team is encoded in the issued tokens and cannot be changed without re-authorization.
Token Refresh
When the access token expires, use the refresh token:
Each refresh token can only be used once. Store the new refresh token from the response.
Security Considerations
- State Parameter: Always validate the
stateparameter to prevent CSRF attacks - PKCE: Use S256 code challenge method (SHA-256)
- Token Storage: Store tokens securely; never expose in URLs or logs
- HTTPS: All OAuth endpoints require HTTPS