Playground
Inspect a simulated OAuth exchange, then decode and verify a sample access token.
Authorization Code + PKCE
Step through the exchange and inspect the HTTP excerpts. All hosts and credentials are fictional.
Dashed messages travel through the browser.
Start connecting the library
User’s browser to Client application
Mina chooses Connect library in Reading List. The client creates a fresh verifier, derives its S256 challenge, and stores the verifier and a random state value with this browser’s pending authorization attempt.
Security Generate a new verifier from at least 32 bytes of cryptographic randomness for each attempt. These fixed values make the example reproducible.
Read the complete transcript
- Start connecting the library
User’s browser to Client application
Mina chooses Connect library in Reading List. The client creates a fresh verifier, derives its S256 challenge, and stores the verifier and a random state value with this browser’s pending authorization attempt.
Security Generate a new verifier from at least 32 bytes of cryptographic randomness for each attempt. These fixed values make the example reproducible.
GET /connect/library HTTP/1.1 Host: reading.example Cookie: __Host-reading_session=demo_session_X4Am - Redirect the browser to the authorization server
Client application to User’s browser
The client returns a Location URL with the authorization parameters. The browser follows it in the next step.
Security The URL carries the challenge and method. The verifier stays on the client until token exchange.
HTTP/1.1 302 Found Location: https://login.example/authorize?response_type=code&client_id=reading-list&redirect_uri=https%3A%2F%2Freading.example%2Foauth%2Fcallback&scope=books%3Aread&state=cUsDG5DE726VtAghyw3Dzw&code_challenge=cuP8PtQCuYvuX1Q8SvpKqsZx96-n56TR_nk4jGiG6QA&code_challenge_method=S256 Cache-Control: no-store - Request authorization with the challenge
User’s browser to Authorization server
The browser visits the authorization endpoint. The client asks for books:read and requests an authorization code.
Security The authorization server validates the client and requires an exact match against this web client’s registered redirect URI.
GET /authorize?response_type=code&client_id=reading-list&redirect_uri=https%3A%2F%2Freading.example%2Foauth%2Fcallback&scope=books%3Aread&state=cUsDG5DE726VtAghyw3Dzw&code_challenge=cuP8PtQCuYvuX1Q8SvpKqsZx96-n56TR_nk4jGiG6QA&code_challenge_method=S256 HTTP/1.1 Host: login.example - Authenticate at the authorization server
User’s browser to Authorization server
The authorization server establishes which library account is active. It might use an existing session or prompt Mina to sign in. The sign-in interaction is specific to the authorization server.
Security Mina authenticates with the authorization server. The client has no access to her library credentials.
- Approve read access
User’s browser to Authorization server
Mina grants Reading List permission to read her saved books. This example shows an approval screen. OAuth leaves the details of the interaction to the authorization server.
Security Request only the permissions the feature needs. Here the client asks for read access to saved books.
- Redirect back with an authorization code
Authorization server to User’s browser
The authorization server issues a short-lived, single-use code associated with the client, redirect URI, and PKCE challenge. It returns the original state value in the redirect.
Security The browser carries a code. Access tokens are returned at the token endpoint.
HTTP/1.1 303 See Other Location: https://reading.example/oauth/callback?code=demo_ac_6GKoZgZq4m&state=cUsDG5DE726VtAghyw3Dzw Cache-Control: no-store - Deliver the code to the client callback
User’s browser to Client application
The browser follows the second redirect. The client checks state against the pending attempt for this browser, then retrieves the verifier for that same attempt.
Security Reject a missing or mismatched state value when this client uses state for callback correlation and CSRF protection.
GET /oauth/callback?code=demo_ac_6GKoZgZq4m&state=cUsDG5DE726VtAghyw3Dzw HTTP/1.1 Host: reading.example Cookie: __Host-reading_session=demo_session_X4Am - Exchange the code and verifier
Client application to Authorization server
The confidential web client authenticates to the token endpoint and sends the code, matching redirect URI, and original verifier over TLS. This request originates from the client backend.
Security PKCE binds the exchange to the initiating attempt. The confidential client also authenticates independently. The Basic credentials shown here are fictional.
POST /token HTTP/1.1 Host: login.example Authorization: Basic cmVhZGluZy1saXN0OmRlbW8tY2xpZW50LXNlY3JldA== Content-Type: application/x-www-form-urlencoded grant_type=authorization_code&code=demo_ac_6GKoZgZq4m&redirect_uri=https%3A%2F%2Freading.example%2Foauth%2Fcallback&code_verifier=Jwmkro0pqtyWTbkt8AqNdlKXNeO6I6bj94bG37g_Pes - Verify the challenge and issue an access token
Authorization server to Client application
The authorization server validates the client, code, and redirect URI. It hashes and base64url-encodes the verifier, compares the result to the stored challenge, consumes the code, and returns an access token.
Security A mismatched verifier fails the exchange with invalid_grant. Token responses carrying credentials must include no-store and no-cache directives in their respective headers.
HTTP/1.1 200 OK Content-Type: application/json Cache-Control: no-store Pragma: no-cache { "access_token": "demo_at_TVW6gksBwL4M", "token_type": "Bearer", "expires_in": 600, "scope": "books:read" } - Request the saved books
Client application to Resource server (API)
Reading List calls the library API with the access token in the Authorization header.
Security Anyone holding a bearer token can present it. Protect it in transit and storage.
GET /v1/saved-books HTTP/1.1 Host: library-api.example Authorization: Bearer demo_at_TVW6gksBwL4M - Check whether the API can accept the token
Resource server (API)
The resource server looks up the opaque token in its trusted token data and checks that it is active, unexpired, intended for this API, and grants books:read for the requested resource.
Security An opaque token has no client-readable claims. This example assumes an internal lookup. A separately deployed API might use authenticated introspection.
- Return the saved books
Resource server (API) to Client application
The API returns Mina’s saved titles to the client. The client can render the result for Mina in its own UI.
HTTP/1.1 200 OK Content-Type: application/json { "books": [ { "id": "bk_17", "title": "Maps of the Tidelands" } ] } - Send the browser to a clean URL
Client application to User’s browser
The backend finishes the pending callback by redirecting to its own saved-books page. The new URL carries no authorization parameters.
Security Avoid third-party resources on the callback page. The clean redirect and restrictive Referrer-Policy limit further exposure of the code through referrers.
HTTP/1.1 303 See Other Location: https://reading.example/saved-books Cache-Control: no-store Referrer-Policy: no-referrer - Open the saved-books page
User’s browser to Client application
The browser loads the client’s page. The client renders the book list and keeps the library access token on the backend.
GET /saved-books HTTP/1.1 Host: reading.example Cookie: __Host-reading_session=demo_session_X4AmHTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 <h1>Saved books</h1><ul><li>Maps of the Tidelands</li></ul>
Inspect a JWT
Read the decoded fields first. Then verify the signature with the lab’s public key and see which claims the library API accepts at a fixed time. The browser uses built-in sample tokens and makes no verification requests.
View compact token
eyJhbGciOiJSUzI1NiIsInR5cCI6ImF0K2p3dCIsImtpZCI6ImxpYnJhcnktZGVtby0xIn0.eyJpc3MiOiJodHRwczovL2xvZ2luLmV4YW1wbGUiLCJzdWIiOiJyZWFkZXItMjQiLCJhdWQiOiJodHRwczovL2xpYnJhcnktYXBpLmV4YW1wbGUiLCJjbGllbnRfaWQiOiJyZWFkaW5nLWxpc3QiLCJpYXQiOjE3NDU0MDk2MDAsImV4cCI6MTc0NTQxMDIwMCwianRpIjoibGlicmFyeS1kZW1vLXRva2VuIiwic2NvcGUiOiJib29rczpyZWFkIn0.e_Zj9Lq3X3fyZMBgbBowksX0PQllDbU_VsmmDp4MtL2y858_GBV2Tk2VKB6ebGwIojy_Yo_NUZfKLEU1TAqqGcjaxt4RtBIgogANJyvudd_Nzh9EsdSdVo5A0hI4vNh4jM430nUJjnCgMSNu2wPJfW8LMBhM2HjTirRHglVRk3sRf5BJGb_L2UFA5TUI4QuHTabEd_3_ZjH5Z43EUK0k_8A3dw5N-F3kSKy7eNGMRjbkCMtj4hxFhpM01hq1qDIeCE9bHLU3o5iaGeVoJRAJIVh9zQ0avI1t_8tPthWQBUqu6nup3yHlUfwUbDabq15CzSLX4vSga6tcTrr7IEJuuADecoded header
{
"alg": "RS256",
"typ": "at+jwt",
"kid": "library-demo-1"
}Decoded claims
{
"iss": "https://login.example",
"sub": "reader-24",
"aud": "https://library-api.example",
"client_id": "reading-list",
"iat": 1745409600,
"exp": 1745410200,
"jti": "library-demo-token",
"scope": "books:read"
}Decoded values are untrusted until verified.
Explore how this compares with PASETO and opaque tokens.