Course contentsShow
← Security
Lesson 771 of 3,05216. Web Security - Authentication MechanismsFree lesson

OIDC Authentication Flows

Understanding Authorization Code Flow, Implicit Flow, and Hybrid Flow in OIDC context and when to use each.

OIDC Authentication Flows

You'll learn: The three main authentication flows in OpenID Connect and when each is appropriate for your application.


What Are OIDC Flows?

OpenID Connect defines several "flows" — structured sequences of requests and responses that authenticate users and deliver tokens to applications. Each flow balances security, complexity, and application architecture differently. The three primary flows are Authorization Code Flow, Implicit Flow, and Hybrid Flow.

Authorization Code Flow

This is the most secure and recommended flow. The application receives an authorization code after user authentication, then exchanges it privately (server-to-server) for an ID token and access token. Because tokens never pass through the browser, they're protected from JavaScript-based attacks.

Use when: You have a backend server that can securely store client secrets and handle token exchanges (traditional web apps, mobile apps with PKCE).

Implicit Flow

Here, tokens are returned directly in the URL fragment after authentication — no code exchange step. This was designed for JavaScript-only applications without backends, but is now deprecated due to security risks (token exposure in browser history, no client authentication).

Use when: Never in new applications. Legacy browser-only apps only.

Hybrid Flow

A combination approach: some tokens come immediately (like Implicit), others require code exchange (like Authorization Code). Rarely needed in modern applications.

Use when: Complex scenarios requiring immediate access to ID tokens while maintaining refresh token security (rare edge cases).

The Right Choice

For almost all modern applications, Authorization Code Flow with PKCE is the answer. It works for web apps, SPAs, and mobile apps while maintaining strong security guarantees. The implicit and hybrid flows exist mainly for backward compatibility.

Key Takeaway: Use Authorization Code Flow (with PKCE) for modern applications; Implicit Flow is deprecated and Hybrid Flow is rarely necessary.