OAuth 2.0 authorization code flow with PKCE

SVG
OAuth 2.0 authorization code flow with PKCE. Sequence diagram with 4 participants (Browser, Web app, Authorization server, Resource API) and 15 messages. 1. Browser to Web app (GET /login); 2. Web app to itself (new code_verifier, S256 code_challenge); 3. Web app to Browser (302 to /authorize (code_challenge, state)); 4. Browser to Authorization server (GET /authorize (client_id, code_challenge)); 5. Authorization server to Browser (sign-in and consent page); 6. Browser to Authorization server (POST credentials, approve scopes); 7. Authorization server to Browser (302 to /callback (code, state)); 8. Browser to Web app (GET /callback (code, state)); 9. Web app to Authorization server (POST /token (code, code_verifier)); 10. Authorization server to itself (SHA-256(code_verifier) = code_challenge?); 11. Authorization server to Web app (access and refresh tokens); 12. Authorization server to Web app (400 invalid_grant); 13. Web app to Resource API (GET /me (Bearer access token)); 14. Resource API to Web app (200 profile); 15. Web app to Browser (session cookie, home page). Fragments: alt [verifier matches] over messages 11 to 12, else [no match] from 12.
drag to pan, scroll or pinch to zoom