Authorization Codes, PKCE, and Redirect Validation
Follow a code from browser authorization to one-time exchange, including exact redirects and the S256 verifier check.
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
Follow the authorization code, not just the login screen
OAuth allows a client to obtain limited access to a resource on behalf of a user or, in another flow, for the client itself. In the authorization code flow, the browser visits an authorization server, the user authorizes access, and the server returns a short-lived code to the registered client callback. The client exchanges that code at the token endpoint.
The authorization server, client, browser, and resource API are different participants. An authorization code is not an access token. It is a temporary artifact whose redemption must be bound to the original client transaction. A successful login screen does not prove those bindings are correct.
Our example is TrailJournal, a public native client asking for read access to a route API. The client cannot keep an embedded application secret confidential. It creates a fresh PKCE verifier and a state value for each pending login before opening the system browser.
Client → authorization endpoint:
response_type=code
client_id=trail-native
redirect_uri=com.example.trail:/oauth/callback
scope=routes:read
state=<fresh transaction value>
code_challenge=<S256 verifier digest>
code_challenge_method=S256
Authorization server → callback:
code=<short-lived code>
state=<same transaction value>