Skip to main content
Debugging OAuth 2.0 Flows in Real Time with Fiddler
API Testing7 min read

Debugging OAuth 2.0 Flows in Real Time with Fiddler

Learn how to debug OAuth 2.0 authorization code, PKCE, and token flows in real time using Fiddler’s HTTPS decryption, filtering, and scripting features.

Share:

OAuth 2.0 is the de facto standard for delegated authorization—but its distributed, multi-step nature makes it notoriously hard to troubleshoot when things go wrong. Redirects, token exchanges, PKCE challenges, and silent failures often leave developers guessing whether the issue lies in client configuration, server policy, or TLS handshake quirks. Fiddler—the industry-standard HTTP debugging proxy—gives you full visibility into every leg of the OAuth flow: from initial authorize redirects to final token responses and subsequent API calls with Bearer tokens. This isn’t just about seeing requests—it’s about understanding context, correlating state across hops, and validating cryptographic parameters like code_verifier, code_challenge, and state in real time.

Why OAuth Debugging Demands a Full-Stack HTTP Proxy

Browser DevTools fall short for OAuth flows because they can’t capture:

  • Cross-origin redirects (e.g., from your app → identity provider → back)
  • Background fetch() or XMLHttpRequest calls triggered by silent refresh logic
  • POST bodies in /token exchanges (often blocked or truncated in DevTools)
  • TLS-level errors before HTTP headers are parsed
  • Certificate pinning bypasses or SNI mismatches affecting /authorize

Fiddler acts as a man-in-the-middle proxy that sits between your browser/app and the network—enabling true end-to-end inspection. With proper https decryption configured, you see plaintext traffic—even for HTTPS endpoints like https://login.microsoftonline.com or https://accounts.google.com. That’s non-negotiable for validating JWT claims, inspecting id_token payloads, or catching malformed application/x-www-form-urlencoded bodies.

Step 1: Configure Fiddler for HTTPS Decryption

Before capturing OAuth traffic, enable TLS interception:

  1. Launch Fiddler → Tools > Options > HTTPS
  2. ✅ Check Decrypt HTTPS traffic
  3. ✅ Check Ignore server certificate errors (for dev/test environments only)
  4. Click Actions > Trust Root Certificate and install the Fiddler root CA in your OS/browser trust store
  5. Restart your browser and confirm the Fiddler icon in the status bar shows “HTTPS” in green

⚠️ Warning: Never enable this on production machines or untrusted networks. For enterprise apps, use Fiddler’s Custom Certificate Generation to avoid system-wide CA trust issues.

This step directly enables reliable [fiddler debugging] of secure OAuth endpoints. Without it, /authorize and /token requests appear as opaque tunnels—rendering token validation, redirect_uri mismatches, and PKCE verification impossible.

Step 2: Capture & Filter OAuth-Specific Traffic

OAuth flows generate noisy traffic—API health checks, analytics beacons, fonts, images. Focus your view:

  • In Fiddler’s Filters tab:
    • Use Filters
    • Under Hosts, enter domains you care about: login.microsoftonline.com, auth0.com, okta.com, or your own auth domain
    • Under Request Headers, add Authorization or Cookie to highlight auth-related requests
  • Use the QuickExec box (bottom-left) to run filtering commands:
    bpu https://login.microsoftonline.com/oauth2/v2.0/token
    
    This breaks before every /token request so you can inspect and even modify the POST body.

Pro tip: Right-click any session → Copy > Copy as cURL to replay token requests in Postman or curl—great for testing error codes like invalid_grant or unauthorized_client.

Step 3: Trace the Full Authorization Code Flow

Assume a typical web app using Authorization Code + PKCE. Here’s how to map each hop in Fiddler:

Identify the Initial Redirect

Look for a 302 Found response with Location: https://<idp>/authorize?.... Expand the request to see query string params:

  • response_type=code → confirms code flow
  • code_challenge & code_challenge_method=S256 → verify PKCE is active
  • state=<random> → copy this value; it must match exactly in the callback
  • redirect_uri=https%3A%2F%2Flocalhost%3A3000%2Fcallback → decode and validate against your app’s registered URI

If the redirect never fires—or returns a 400 Bad Request—check decoded redirect_uri against your IdP’s allowed list. Fiddler’s WebForms inspector auto-decodes URL-encoded values.

Inspect the Callback Request

After login, the IdP redirects back to your redirect_uri with ?code=...&state=.... In Fiddler:

  • Find the GET request to your callback endpoint
  • Confirm state matches the original (critical for CSRF protection)
  • Verify code is present—and not an error like error=access_denied

Then trace the immediate follow-up: your app’s POST /token request. Click it → Inspectors > WebForms tab shows the raw body:

grant_type=authorization_code
&code=eyJhbGciOiJSUzI1NiIs...
&redirect_uri=https%3A%2F%2Flocalhost%3A3000%2Fcallback
&client_id=your-client-id
&code_verifier=J9vQX...

✅ All fields must align with the initial /authorize call. A mismatched code_verifier or expired code triggers invalid_grant—visible instantly in the response JSON.

Step 4: Decode & Validate Tokens On-the-Fly

Fiddler doesn’t parse JWTs by default—but with a tiny customization, it does:

  1. Go to Rules > Customize Rules (Ctrl+R)
  2. Paste this into the OnBeforeResponse function:
if (oSession.uriContains("/token") && oSession.responseCode == 200) {
    var body = oSession.GetResponseBodyAsString();
    if (body.Contains("id_token") || body.Contains("access_token")) {
        var json = JSON.parse(body);
        if (json.id_token) {
            var parts = json.id_token.split('.');
            if (parts.length == 3) {
                var payload = Utilities.Base64Decode(parts[1]);
                oSession.oResponse.headers.Add("X-ID-Token-Payload", payload);
            }
        }
    }
}
  1. Save → Fiddler will now add a custom header X-ID-Token-Payload containing the decoded JWT payload

Now right-click any /token response → Inspectors > Headers → scroll to X-ID-Token-Payload. You’ll see:

{
  "iss": "https://login.microsoftonline.com/.../v2.0",
  "sub": "Yb7K...",
  "aud": "your-client-id",
  "exp": 1718212438,
  "iat": 1718208838,
  "nonce": "abc123"
}

Compare aud, exp, and nonce against your expectations. An aud mismatch means your client ID isn’t whitelisted. An expired exp suggests clock skew—visible here before it breaks your app.

For deeper analysis, export the token and paste it into jwt.io — but Fiddler’s inline decoding saves minutes per debug cycle.

Step 5: Troubleshoot Silent Failures & CORS Issues

Not all OAuth problems surface as HTTP errors. Common silent failures include:

  • CORS preflight rejection: Look for OPTIONS requests failing with 403 Forbidden or missing Access-Control-Allow-Origin. Fiddler shows full request/response headers—confirm Origin matches your app’s domain and Access-Control-Allow-Credentials: true is set if using cookies.
  • Token not attached to API calls: After /token, find subsequent GET /api/me requests. Check Inspectors > Headers for Authorization: Bearer <token>. If missing, your app’s auth interceptor failed—Fiddler proves it’s not a network issue.
  • PKCE code_verifier truncation: Some frameworks strip + or / from Base64-encoded code_verifier. In Fiddler, compare the code_verifier sent in /token against the one generated during /authorize. Use TextWizard (right-click → Transform → Base64 Decode) to validate encoding.

Use Fiddler’s AutoResponder to mock IdP behavior: return a fake access_token or inject a delay to test timeout handling. This is invaluable for [fiddler tutorial] scenarios where you control neither the client nor the identity provider.

Bonus: Debug Mobile & Desktop OAuth Clients

Fiddler isn’t just for browsers. To debug iOS/Android apps or Electron desktop clients:

  • Configure device/desktop to use Fiddler as HTTP proxy (IP:port = your machine’s LAN IP + 8888)
  • Install Fiddler’s root certificate on the device (more tutorials)
  • For Android: enable android:usesCleartextTraffic="true" in AndroidManifest.xml only for debug builds
  • For iOS: enable full trust for the Fiddler cert under Settings > General > About > Certificate Trust Settings

Once connected, filter by Host and watch /authorize, /token, and /userinfo calls flow through Fiddler—just like in-browser. This is essential for [fiddler debugging] hybrid mobile auth where WebView behavior differs from Chrome.

Conclusion: Turn OAuth Guesswork Into Precision Debugging

OAuth 2.0 isn’t broken—it’s complex by design. But complexity shouldn’t mean blind troubleshooting. With Fiddler configured for [https decryption], filtered for auth domains, and extended with lightweight scripting, you transform opaque redirects and cryptic error codes into auditable, reproducible HTTP transactions. You’ll catch redirect_uri typos before QA, validate PKCE integrity in seconds, and decode JWT claims without leaving your proxy.

Key takeaways:

  • Always enable HTTPS decryption first—no exceptions for OAuth endpoints
  • Use bpu breakpoints on /token to intercept and modify requests
  • Leverage Fiddler’s WebForms and TextWizard for rapid URL/encoding inspection
  • Add custom headers to auto-decode tokens—no external tools needed
  • Extend visibility beyond browsers to mobile and desktop clients

Mastering [fiddler proxy] techniques for OAuth isn’t optional—it’s the fastest path from “Why won’t this work?” to “Here’s the exact line causing the failure.” For more advanced scenarios like OpenID Connect discovery or JWT signature verification, browse API Testing tutorials. And if your flow involves custom grant types or legacy SAML bridges, contact us for tailored debugging strategies.

Fiddler turns HTTP debugging from reactive triage into proactive engineering. Start capturing—not just assuming—today.

Share:

Related Topics

fiddler tutorialfiddler debugginghttp debuggingfiddler proxyhttps decryption

Get Fiddler Tips & Tutorials

Stay updated with the latest Fiddler tutorials, HTTP debugging guides, request modification tips, and web traffic analysis techniques.

Free forever. New tutorials published daily.

Related Articles