Skip to main content

OAuth2 Flow Tester

Test and debug OAuth2 authorization code flows. Generate cryptographically secure PKCE code_verifier and code_challenge pairs, build authorization URLs with correct parameters, and generate token exchange requests. Step-by-step simulation of the complete OAuth2 + PKCE flow.

✓ PKCE S256 code generation ✓ Authorization URL builder ✓ Token exchange request template

Frequently Asked Questions

What is PKCE and why is it required?▼

PKCE (Proof Key for Code Exchange, pronounced 'pixy') prevents authorization code interception attacks. The client generates a random code_verifier, computes its SHA-256 hash (code_challenge), and sends the hash with the authorization request. When exchanging the code for tokens, the client sends the original verifier. Even if an attacker intercepts the authorization code, they can't get tokens without the verifier — which was never sent in the initial request. PKCE is now required for all OAuth 2.0 public clients (RFC 9700).

What is the difference between Authorization Code and Implicit flow?▼

Authorization Code flow: the authorization server returns a short-lived code, which the client exchanges for tokens via a server-to-server request. The access token never appears in URLs. Implicit flow (now deprecated): the authorization server returns the access token directly in the URL fragment (response_type=token). Tokens in URLs are logged by browsers, proxies, and CDNs — a significant security risk. Always use Authorization Code + PKCE instead of Implicit.

What is the 'state' parameter for?▼

The 'state' parameter is a CSRF (Cross-Site Request Forgery) token. Your app generates a random value before redirecting to the authorization server, includes it in the auth URL, and verifies it matches when the user is redirected back with the authorization code. Without state validation, an attacker can initiate an auth flow and trick a victim into completing it, linking the attacker's account to the victim's identity.

What scopes should I request?▼

Request only the minimum scopes needed (principle of least privilege). For OpenID Connect: 'openid' is required for an ID token. 'profile' adds name/picture. 'email' adds email address. 'offline_access' requests refresh tokens for long-lived sessions. For API scopes, use resource-specific scopes (e.g. 'read:messages write:messages') rather than broad admin scopes. Users are more likely to consent to narrow, specific scopes.

How does the token exchange work?▼

After the user approves and the server redirects back with ?code=AUTH_CODE, your backend sends a POST request to the token endpoint with: grant_type=authorization_code, the code, redirect_uri (must match exactly), client_id, and code_verifier (for PKCE). The server verifies the verifier matches the challenge, then returns an access_token, optional refresh_token, and optional id_token. Never do the token exchange from client-side JavaScript — the code is only valid once.

What is the difference between access tokens and refresh tokens?▼

Access tokens are short-lived credentials (typically 15 minutes to 1 hour) that authorize API calls. Include them in the Authorization header: 'Bearer <token>'. Refresh tokens are long-lived (days to months) and are used only to obtain new access tokens when the current one expires. Refresh tokens must be stored securely (HttpOnly cookies or secure server storage) — if leaked, they allow prolonged unauthorized access. Rotate refresh tokens on each use.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

JWT Decoder OpenAPI Validator API Response Mock Generator API Response Time Tester JWT Builder OpenAPI Schema Validator OAuth2 Flow Visualizer OpenAPI Mock Generator OAuth2 Flow Debugger API Test Case Generator API Request Builder HTTP Security Headers Generator JWT Debugger Pro API Mock Server Config Generator HTTP Security Headers Checker authentik API Key Generator API Rate Limit Calculator API Response Formatter & Analyzer HTTP API Tester LLM Cost Calculator AI Prompt Cost Calculator REST API Request Builder Content Security Policy Builder LLM Prompt Cost Calculator API Response Mocker HTTP Header Inspector AI Rate Limit Calculator Prompt Injection Tester GCP Service Account Key Auditor HTTP Headers Analyzer AI Doc Generator — Pro Tool AI System Guardian .htaccess Generator HTTP Methods Reference HTTP Code Snippet Generator HTTP Status Code Reference HTTP Status Code Reference JSON Diff Viewer JSON Diff nginx Config Generator Password Strength Checker Rate Limiter Tester API Changelog Generator HTTP Mock Response Builder HMAC Generator CSP Header Builder Rate Limit Calculator CORS Policy Builder AWS IAM Policy Validator HTTP Cookie Parser SBOM Generator HTTP Status Code Lookup TOTP Code Generator HTTP Status Code Lookup Vue Component Generator HTTP Status Code Reference LLM Context Window Calculator HTTP Header Analyzer LLM Token Counter Dockerfile Linter mTLS Certificate Chain Builder Prompt Token Estimator Mock Service Worker (MSW) API Mocking Guide Pulumi Modern IaC Guide HashiCorp Vault Secrets Management Guide AES Encryptor / Decryptor Casdoor Docker Layer Optimizer HTML5 Canvas API Playground Token Context Calculator GraphQL Client Configurator Axios Interceptor Builder OpenAI Function Calling Generator Token Counter & Cost Estimator AI API Rate Limit Calculator Password Strength Analyzer

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →