OpenID Connect Hybrid Flow: when authorization returns both an ID Token and a code
The OpenID Connect Hybrid Flow returns an authorization code and one or more tokens from the authorization endpoint, then exchanges the code at the token endpoint. For example, `code id_token` returns a code and ID Token through the browser, then the code exchange can return an access token. Because browser-delivered responses expose more data and require more checks, prefer authorization code flow for a new design unless a specific requirement needs hybrid flow. This article covers reviewing an existing web client, not recommending legacy combinations for new builds.
OpenID Connect Hybrid Flow: when authorization returns both an ID Token and a code
The OpenID Connect Hybrid Flow returns an authorization code and one or more tokens from the authorization endpoint, then exchanges the code at the token endpoint. For example, code id_token returns a code and ID Token through the browser, then the code exchange can return an access token. Because browser-delivered responses expose more data and require more checks, prefer authorization code flow for a new design unless a specific requirement needs hybrid flow. This article covers reviewing an existing web client, not recommending legacy combinations for new builds.
Response combinations
response_type | Authorization endpoint response | Default mode |
|---|---|---|
code id_token | code and ID Token | fragment |
code token | code, access token, token type | fragment |
code id_token token | code, ID Token, access token, token type | fragment |
Hybrid requests require the openid scope. OIDC Core requires a fresh nonce for code id_token and code id_token token; it is optional for code token. Validate the response, and validate any ID Token's signature, issuer, audience, time claims, and nonce before creating a login session or granting access. For ID Tokens returned with a code, compare c_hash with that code. If the same response also returns an access token (code id_token token), compare the required at_hash with that token. Use the hash algorithm associated with the ID Token JOSE alg. Exchange the code only in its original transaction, with the matching redirect URI and PKCE verifier where PKCE is used.
Trade-offs and review steps
Hybrid flow can combine early front-channel results with a back-channel code exchange. But tokens in browser responses expand exposure: fragments are not sent in the HTTP request path, yet browser scripts and history can see them; query values can enter logs and Referer headers. Evaluate the response mode and token type together.
Ask whether the client needs a token immediately at the authorization endpoint. If not, code flow with PKCE is often simpler.
Record the exact `response_type` values in use and disable unused token-returning combinations.
Bind `state`, issuer identification, response parsing, code exchange, and ID Token validation to one transaction.
Keep sensitive query/fragment values out of server and proxy logs, analytics scripts, and Referer data.
If requirements allow migration, move to code flow and confirm no legacy client or provider interoperability need remains before disabling unused response types.
These are review recommendations, not tests performed on a specific deployment.
Sources
[OpenID Connect Core 1.0 §3.3: Hybrid Flow](https://openid.net/specs/openid-connect-core-1_0.html#HybridFlowAuth)
[OAuth 2.0 Multiple Response Type Encoding Practices](https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html)
[RFC 9700: OAuth 2.0 Security Best Current Practice](https://www.rfc-editor.org/rfc/rfc9700.html)