Quiz Entry - updated: 2026.10.22
What must be done to implement OAuth 2.0 securely?
Choose the right flow, store tokens and key material securely, limit the lifetime of authorization codes and access tokens, and use HTTPS for all communication (plus the measures of the OAuth security best practice).
- The right flow: authorization code with PKCE whenever a user is involved, client credentials for machine-to-machine; never implicit or password grant. Picking the wrong flow can expose tokens no matter how carefully the rest is built.
- Secure storage of tokens and keys: client secrets and refresh tokens belong in server-side storage or the platform's secure keystore, not in browser local storage or source code.
- Short lifetimes: codes valid for minutes and used once, access tokens valid for minutes to hours. Short lifetimes turn a leaked artefact into a brief problem instead of a permanent one.
- HTTPS everywhere: bearer tokens and codes are only as safe as the channel; plain HTTP hands them to anyone on the network.
The current reference for everything beyond these basics is the OAuth 2.0 Security Best Current Practice (RFC 9700, published in 2025): exact redirect URI matching, PKCE for all clients, state or PKCE against CSRF, sender-constrained or rotating refresh tokens, and audience-restricted access tokens.
Go deeper:
RFC 9700: Best Current Practice for OAuth 2.0 Security — the authoritative list of current security recommendations.
RFC 6749, Section 10: Security Considerations — the original threat discussion of the framework.