OAuth 偵錯器
Privacy First偵錯 OAuth 2.0/PKCE 驗證流程。
PKCE Generator
Click Generate to create a cryptographically random code_verifier and derive its SHA-256 code_challenge.
Authorization URL Builder
Security Analyzer
Describe your OAuth configuration and get security recommendations.
Security Findings
What is PKCE and Why Does It Matter?
Proof Key for Code Exchange (PKCE, RFC 7636) was originally designed for mobile and native apps that cannot securely store a client secret. It works by having the client generate a random code_verifier, derive a code_challenge from it (SHA-256 + base64url), and send the challenge with the authorization request. When exchanging the authorization code for tokens, the client sends the original code_verifier. The authorization server verifies it matches the earlier challenge — proving the token request came from the same client that started the flow.
Even for confidential clients (server-side apps with a client secret), PKCE is now recommended by OAuth 2.1 as a defense against authorization code interception attacks.
Why Is the Implicit Flow Deprecated?
The implicit flow (response_type=token) was designed as a shortcut for single-page apps, returning the access token directly in the URL fragment. This creates serious problems: tokens in URLs appear in browser history, server logs, and referrer headers, and the flow is vulnerable to token injection attacks. OAuth 2.0 Security Best Current Practice (RFC 9700) and OAuth 2.1 explicitly remove the implicit flow in favor of Authorization Code + PKCE, which SPAs can use safely without a client secret.
Key OAuth 2.1 Changes
- PKCE required for all Authorization Code flows, including confidential clients.
- Implicit flow removed — use Authorization Code + PKCE instead.
- Resource Owner Password Credentials (ROPC) removed — the
passwordgrant type is deprecated. - Refresh token rotation required for public clients — a new refresh token must be issued with each use.
- Redirect URI exact matching required — no pattern matching or wildcards.
Authorization Code Flow Step by Step
- Generate PKCE pair: Create a random
code_verifierand computecode_challenge = BASE64URL(SHA256(code_verifier)). - Redirect to authorization endpoint: Include
response_type=code,client_id,redirect_uri,scope,state,code_challenge, andcode_challenge_method=S256. - User authenticates at the authorization server and grants consent.
- Receive authorization code at your
redirect_urialongside the echoedstate— verifystatematches what you sent. - Exchange code for tokens: POST to the token endpoint with
grant_type=authorization_code,code,redirect_uri,client_id, andcode_verifier. - Receive access token (and optionally
id_tokenandrefresh_token) and use them to call APIs.