OAuth Flow
email-connector implements OAuth 2.0 Authorization Code with PKCE (RFC 7636) using the S256 challenge method. This is the same pattern used by mobile apps and SPAs where the client cannot securely store a secret.Why OAuth + PKCE?
Claude’s MCP connector system uses OAuth to authorize third-party tools. PKCE adds a layer of protection that prevents authorization code interception — even if someone captures the code in transit, they cannot exchange it for a token.Step-by-Step Flow
1. Authorization Request
Claude opens the authorization endpoint in a browser popup:response_typemust becodeclient_idmust match the server’s configured client IDredirect_urimust be in the allowlistcode_challenge_methodmust beS256stateis required (CSRF protection)
400 or 401 error.
2. User Authorization
email-connector renders the setup form where you:- Select your email provider
- Enter your email address
- Enter your app-specific password
3. Authorization Code
On successful validation:- The server generates a 48-character random authorization code
- Stores the code with the associated credentials and PKCE challenge
- Redirects to Claude’s callback URL:
4. Token Exchange
Claude exchanges the authorization code for an access token:- Validates
client_idandclient_secret - Computes
BASE64URL(SHA256(code_verifier))and compares it to the storedcode_challenge - Verifies
redirect_urimatches the original request - If everything checks out, returns an access token
5. Token Response
Bearer token in all subsequent MCP requests.
Token Revocation
To revoke access:200 OK with {"revoked": true} regardless of whether the token was valid. This prevents token existence probing.
Error Responses
| Error | Cause |
|---|---|
unsupported_grant_type | Only authorization_code is supported |
invalid_client | Wrong client_id or client_secret |
invalid_request | Missing code_verifier |
invalid_grant | Code expired, already used, or PKCE mismatch |