Course contentsShow
← Software Engineering
Lesson 1023 of 1,93331. Authentication and AuthorizationFree lesson

OpenID Connect (OIDC) and ID Tokens

Adding authentication to OAuth2 with OIDC, understanding ID tokens and the UserInfo endpoint.

OpenID Connect (OIDC) and ID Tokens

You'll learn how OpenID Connect extends OAuth2 to provide user authentication, not just authorization.

The Missing Piece in OAuth2

OAuth2 solves authorization (delegating access to resources), but it doesn't tell you who the user is. You get an access token to call APIs, but OAuth2 has no standard way to retrieve user identity information. OpenID Connect (OIDC) fills this gap by adding an authentication layer on top of OAuth2.

Think of it this way: OAuth2 is like getting a hotel key card (access to your room), but OIDC also gives you a photo ID proving you are the guest who checked in.

The ID Token

OIDC introduces the ID token, a JSON Web Token (JWT) that contains claims about the authenticated user's identity. When you complete an OIDC authentication flow (typically using the Authorization Code Grant), you receive both an access token and an ID token.

The ID token includes claims like:

  • sub (subject): unique user identifier
  • email: user's email address
  • name: user's display name
  • iss (issuer): who created the token
  • aud (audience): who the token is for
  • exp (expiration): when it expires

The ID token is always a JWT and must be validated on the client side to verify authenticity.

The UserInfo Endpoint

For additional user details not included in the ID token, OIDC provides a standardized UserInfo endpoint. You call this endpoint using the access token to retrieve extended profile information about the authenticated user—things like profile picture, phone number, or address.

Key Takeaway: OpenID Connect extends OAuth2 to provide identity authentication through ID tokens (JWTs containing user claims) and the UserInfo endpoint, transforming OAuth2 from pure authorization into a complete authentication solution.