An OAuth authorization-code flow returns a short-lived authorization code to your redirect URI; your client then exchanges that code at the token endpoint for tokens. For a public client, use PKCE with a unique verifier and an S256 challenge. The examples below show the protocol shape, but the authorization and token endpoint URLs, client registration, authentication method, scopes, and SDK calls must come from your identity provider’s current documentation.
What an OAuth authorization-code example should show
The authorization code is not an access token. It is an intermediate credential delivered through the browser redirect, then presented to the token endpoint. The token endpoint returns tokens only after it validates the code and the relevant client, redirect URI, and PKCE checks. This distinction is central to the OAuth 2.0 authorization-code grant defined in RFC 6749 and illustrated in OAuth.com’s authorization-code example.
- The client generates transaction-specific state and, when using PKCE, a verifier plus its S256 challenge.
- The user agent is redirected to the authorization server with the client ID, registered redirect URI, requested scopes, state, challenge, and
code_challenge_method=S256. - The user authenticates and authorizes at the authorization server. The application should not collect the user’s password by asking for it directly.
- The authorization server redirects the user agent to the registered redirect URI with a code and the state value, where used.
- The client checks that the callback matches the transaction it initiated, then submits the code and original verifier to the token endpoint.
- The client uses the returned access token with the protected API according to that API’s requirements.
Use PKCE and bind each login to its own transaction
The IETF’s January 2025 OAuth 2.0 Security Best Current Practice (RFC 9700) says public clients MUST use PKCE to prevent authorization-code injection and misuse; confidential clients are RECOMMENDED to use it as well. The verifier and challenge must be specific to the transaction and securely bound to the client and user agent. Never reuse a fixed verifier or challenge across logins.
Use the S256 challenge method. RFC 9700 says clients SHOULD use a method that does not expose the verifier in the authorization request and states, “Currently, S256 is the only such method.” If the authorization request includes a valid code challenge, the authorization server must enforce the corresponding verifier during token exchange and mitigate downgrade attempts.
#1 Best Overall
Language-neutral implementation sketch
This pseudocode shows the required data flow. The values marked as provider-specific are not universal endpoint URLs or settings; obtain them from the chosen provider’s current documentation and app registration.
- Generate a cryptographically random verifier for this login and keep it in transaction-scoped storage accessible to the callback handler. Generate a random state value and bind it to the same transaction.
- Compute
challenge = BASE64URL_NO_PADDING(SHA256(UTF8(verifier))). Store the verifier, state, and any other callback correlation data until the flow completes or expires. - Redirect the user agent to the provider’s authorization endpoint with
response_type=code,client_id, the exact registeredredirect_uri, requestedscope,state,code_challenge, andcode_challenge_method=S256. Add provider-required parameters, such as OpenID Connect parameters, only as documented by that provider. - At the redirect URI, reject missing, mismatched, expired, or already-consumed state. Handle authorization-server error responses as errors, not as successful callbacks. Accept the code only for the transaction associated with validated state.
- Send a form-encoded token request to the provider’s token endpoint with
grant_type=authorization_code, the code, the same exact redirect URI where required, the client identifier, and the original verifier. A confidential client must authenticate as required by its provider and registration. - Validate the token response and store tokens according to the application’s threat model and platform. Use the access token only as the protected resource API specifies; design refresh behavior from the provider’s current rules.
Server-side web app versus browser or native client
The protocol’s broad sequence stays the same, but a client’s ability to keep secrets changes implementation choices. RFC 9700 distinguishes public and confidential clients; Microsoft Learn’s authorization-code flow guidance shows a provider-specific PKCE and OpenID Connect variant. Treat that as an example for that platform, not a universal endpoint or SDK contract.
Rank #2
- Ultra-Compact FIDO2 Security Key - Plug-and-stay or carry on a keychain. This USB-A hardware security key offers portable, always-on protection for desktop and mobile use. (Item Size: 0.75 X 0.74 IN x 0.25 IN)
- USB-A Hardware Key for All Devices - Works with USB-A ports on PC, Mac, Android, and other laptop/notebook device. Enables secure, cross-platform login with FIDO2.0 passkey support.
- FIDO Certified Security Key - Meets FIDO and FIDO2 standards. Works with Google, Microsoft, GitHub, Dropbox, and more. Please check service compatibility before purchase.
- Passwordless Login with Passkey - Supports passkey login via WebAuthn and CTAP2. Enjoy password-free sign-ins where supported. Not all websites or services currently support passkeys.
- Advanced Multi-Factor Authentication - Offers 200 FIDO2 passkey slots and 50 OATH-TOTP slots. Strong, flexible 2FA/MFA support across various apps and authentication platforms.
| Concern | Server-side web app | Browser or native public client |
|---|---|---|
| Can it protect a client secret? | A backend may be registered as confidential and authenticate as the provider requires. Keep its secret on the server. | Installed apps and browser-delivered code cannot reliably keep a shared secret confidential; do not embed one as if it were secret. |
| PKCE | Recommended for confidential clients under RFC 9700; use a transaction-specific verifier. | Required for public clients under RFC 9700; use a transaction-specific verifier. |
| Verifier and token handling | Keep verifier and tokens in appropriate server-side transaction and session storage. | Keep verifier in transaction-bound app storage and choose token storage appropriate to the platform’s security model. |
| Redirect reception | A registered web callback route receives the authorization response. | A registered app or browser redirect mechanism receives it; exact setup depends on the platform and provider. |
| Authentication and refresh | Provider registration determines client authentication, scopes, and refresh-token behavior. | Provider registration and platform guidance determine supported behavior; do not assume a browser/native flow shares server-side secret handling. |
Implementation details to verify for your provider
- Endpoints and registration: use the provider’s current authorization and token endpoint URLs, allowed redirect URI configuration, client type, and authentication method.
- Redirect matching: send the redirect URI that corresponds exactly to the registered value and to the transaction; providers may enforce exact matching.
- State and callback validation: compare returned state with the state stored for the initiating transaction before accepting the code. Define expiry and one-time consumption behavior.
- Scopes and token use: request only needed scopes. The authorization server’s token response and the resource API’s authorization requirements are provider-specific.
- OpenID Connect: if the app needs identity information, follow the provider’s OpenID Connect documentation, including required request parameters and validation; an OAuth access token alone is not a substitute for an identity-validation flow.
- Token storage and refresh: select storage and refresh behavior for the app type and provider. Do not assume every provider issues refresh tokens or applies the same rotation and expiration rules.
- SDK signatures: use the provider’s current library documentation for exact method names and parameters. The protocol-level sketch above is not a drop-in SDK call.
Troubleshooting common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| Token endpoint rejects the code | The code may be expired, already used, associated with a different client or redirect URI, or submitted with the wrong verifier. | Run a fresh authorization transaction; confirm the exact client, redirect URI, and transaction’s original verifier are used. Authorization codes are for exchange, not reuse. |
| PKCE verification fails | The stored verifier was lost, overwritten by another login, or does not derive the challenge sent in the authorization request. | Keep verifier state isolated per transaction; recompute S256 and base64url encoding without padding; ensure the same verifier reaches the exchange. |
| Callback is rejected by the application | State is absent or does not match, the transaction expired, or an authorization error was treated as a code response. | Validate state against the initiating transaction, enforce expiry and one-time use, and handle error parameters separately. |
| Redirect URI mismatch | The request, token exchange, and provider registration do not use the expected URI value. | Compare the configured URI and both requests character-for-character, following the provider’s registration rules. |
| Client authentication fails | A confidential client is using the wrong method or credentials, or public-client code is attempting to ship a secret. | Check client type and the provider’s registered token-endpoint authentication method. Never put a confidential secret in browser-delivered or installed public-client code. |
| Access token works for one API but not another | The resource API may require different scopes, audience, or authorization conditions. | Follow that API’s provider documentation and request only its supported authorization parameters. |
Performance, reliability, and cost considerations
The redirect and token exchange are interactive protocol steps, so an implementation should preserve the state and verifier for the duration of the transaction rather than trying to recreate them after a callback. Avoid logging authorization codes, verifiers, secrets, or tokens. Handle authorization-server errors, network failures, and expired transactions by starting a new authorization request instead of replaying a stale code.
OAuth itself does not prescribe a universal SDK, deployment architecture, token lifetime, refresh policy, or operational cost. Those depend on the identity provider, application platform, and protected API. Confirm current provider documentation and registration settings before deployment.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #3
- Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
- Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
- Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
- Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
- For the driver download and user guide, please visit TrustKey Solutions Home support page.
Or skip the browser setup
For developers who need website screenshots rather than OAuth tokens, ScreenshotNeo is a separate website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. Its clean-shot flow accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and whether the capture was billed.
Example cURL call, with the API key and target URL replaced for your use:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month with no card.
Rank #4
- Tamper Resistant Star Key Set Crafted with premium chrome vanadium steel, and each star tool folds neatly into the handle for quick, easy access.
- Details - The handle is engraved with size for quick identification with drilled tips to allow use.
- Portable - Keys fold compact for easy storage, Drilled tips allow use on tamper resistant security screws.
- Size:Full Size T-6, T-7, T-8, T-9, T-10, T-15 T-20, T-25, T-27 and T-30.
- And with 10 total star sizes able to match nearly all standard tamper resistant security screws on the market.
Frequently Asked Questions
Does the authorization-code callback return an access token?
No. It returns an authorization code; the token endpoint exchanges that code for tokens.
Should a confidential web app use PKCE?
RFC 9700 recommends PKCE for confidential clients, while requiring it for public clients.
Can I use the same PKCE verifier for every login?
No. The verifier must be unique to and securely bound to each authorization transaction.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

