Skip to content

// diagrams › security

OpenID Connect sign-in: authorization code flow with PKCE

OpenID Connect adds identity to OAuth 2.0: a signed ID token that tells an app who signed in. The sign-in flow drawn step by step, what is inside an ID token and how to validate it, which token goes where, logout, and when to use OIDC, OAuth or SAML.

Opens a copy in the editor, in a new tab, ready to change. No account needed.

OpenID Connect sign-in with the authorization code flow and PKCE: the app redirects you to the provider's /authorize with scope openid, a nonce and a code challenge; you authenticate; the app exchanges the code at /token for an ID token and access token, validates the ID token against the signing keys and optionally calls /userinfo.

What’s in this diagram

services and parts

  • You
  • App you sign in to (relying party)
  • /authorize (authentication)
  • /token endpoint
  • Signing keys (JWKS)
  • /userinfo

groups

  • OpenID provider

Key points

  • OAuth gives an app an access token for an API. OpenID Connect adds an ID token that tells the app who signed in.
  • Ask for scope=openid and use the authorization code flow with PKCE. It is the same OAuth flow with one more token back.
  • The ID token is for the app, never for an API. The access token is for the API, and the app should not read it.
  • Validate every ID token: signature, issuer, audience, expiry and nonce.

The whole story, step by step: OpenID Connect explained: ID tokens, flows and when to use OIDC.

Your diagram is one sentence away.

Start drawing, free

No account needed to start.