English · IndiaLog in
Rackwave Technologies
Request quote Free consultation
IntegrationUpdated 25 Nov 2026

What Is OpenID Connect (OIDC)? Flows and Tokens

OpenID Connect explained: tokens, flows, OAuth and SAML comparison, security and setup.

Written by Arjun Mehta
  • Published25 Nov 2026
  • Read time6 min
  • Length1,260 words
Share this guide

What is OpenID Connect? OpenID Connect, or OIDC, is an identity layer built on top of the OAuth 2.0 protocol that lets applications verify who a user is and obtain basic profile information from an identity provider. While OAuth 2.0 handles delegated authorisation, giving an app limited access to resources, OIDC adds authentication through a signed ID token in JSON Web Token format. It is the standard way to implement sign in with a company or social account in modern web, mobile and single page applications, and it powers many single sign-on deployments. This guide explains how OIDC works, its tokens and flows, how it compares with OAuth and SAML, security best practices and a step by step implementation approach.

Short answer: OpenID Connect adds authentication to OAuth 2.0. After the user signs in at an identity provider, the application receives an ID token that proves who the user is, plus access tokens for APIs.

What is OpenID Connect?

The OpenID Connect article on Wikipedia describes it as an authentication layer over OAuth 2.0. It extends OAuth, is an alternative to SAML for single sign-on and underpins secure API security for mobile and web clients.

Key OIDC concepts and tokens

Diagram of the OpenID Connect authorization code flow between user, client application and identity provider with ID token and access token
Figure 1. The authorisation code flow with PKCE returns an ID token for sign in and an access token for APIs.
ConceptMeaning
Relying party (client)The application that wants to authenticate the user
OpenID provider (IdP)The service that authenticates the user and issues tokens
ID tokenA signed JWT containing claims about the authentication and the user
Access tokenA credential for calling protected APIs
Refresh tokenA long lived credential to obtain new access tokens
ScopesRequested permissions, such as openid, profile and email
ClaimsPieces of information about the user, such as subject and email
UserInfo endpointAPI returning more profile claims
Discovery documentA well known URL listing endpoints and keys

How the authorisation code flow works

  1. The client redirects the user to the IdP authorisation endpoint with scope openid, a state value and a PKCE code challenge.
  2. The user authenticates, using MFA if required, and consents if needed.
  3. The IdP redirects back with a short lived authorisation code.
  4. The client exchanges the code, with the PKCE verifier, at the token endpoint.
  5. The IdP returns an ID token, an access token and optionally a refresh token.
  6. The client validates the ID token signature, issuer, audience, nonce and expiry, then creates a session.

OIDC compared with OAuth 2.0 and SAML

ItemOAuth 2.0OpenID ConnectSAML 2.0
PurposeDelegated authorisationAuthentication on top of OAuthEnterprise federated authentication
Token formatOpaque or JWT access tokensJWT ID token plus access tokenXML assertion
Best forAPI accessWeb, mobile, SPA sign inLegacy and enterprise web apps
ComplexityModerateModerateHigher, XML heavy
Mobile and API friendlyYesYesLess so

Common OIDC flows

FlowUseNotes
Authorisation code with PKCEWeb, mobile and single page appsRecommended default
Client credentialsMachine to machine accessNo user, so no ID token
Device authorisationTVs and devices without browsersUser approves on another device
Implicit and hybridOlder patternsAvoid implicit in new designs
Refresh tokenRenewing sessionsProtect, rotate and bind where possible

Security best practices

  • Use the authorisation code flow with PKCE for every public client.
  • Validate the ID token fully: signature, issuer, audience, expiry and nonce.
  • Use exact redirect URI matching and the state parameter against CSRF.
  • Keep tokens short lived, rotate refresh tokens and store them securely.
  • Do not use ID tokens to call APIs, and do not trust access tokens in the browser for sensitive data.
  • Rotate signing keys and fetch them through the discovery document.

How to implement OpenID Connect

  1. Choose an identity provider. Use an enterprise IdP or customer identity platform with OIDC support and a certified library.
  2. Register the application. Create a client, set redirect URIs and select scopes.
  3. Implement the code flow with PKCE. Use a well maintained library rather than custom token handling.
  4. Validate tokens and map claims. Check all token fields and map claims to roles and permissions in the app.
  5. Secure sessions and APIs. Use secure cookies or backend for frontend patterns and validate access tokens at APIs.
  6. Handle logout and refresh. Implement session timeout, refresh rotation and sign out across applications.
  7. Test and monitor. Run security tests, log failures and watch for unusual patterns.

Our API development service builds secure OIDC enabled applications and APIs, and our system integration service connects them to your identity provider.

A worked example: sign in for a customer portal

A B2B portal wants customers to sign in with their own corporate accounts and also offers email sign in for smaller clients. The team integrates an OIDC capable identity platform, using the authorisation code flow with PKCE from a single page app through a thin backend. The ID token supplies the subject, email and organisation claim, which the portal maps to a tenant and a role.

APIs accept short lived access tokens and check audience and scopes on every call. Refresh tokens rotate on use, and a central dashboard shows sign in failures by tenant. When a large customer asks for single sign-on with its own provider, the team adds that IdP as a federated connection in hours rather than weeks.

Claims, scopes and authorisation design

OIDC proves who the user is, but your application still decides what they may do. Keep identity claims small and stable, such as subject, email and organisation, and map them to roles inside your own system or through a central authorisation service. Request only the scopes you need, avoid putting sensitive data in tokens that travel through browsers and design APIs to check scopes, audience and tenant on every request rather than trusting the front end.

Common mistakes and troubleshooting

Frequent problems include mismatched redirect URIs, clock skew that makes tokens appear expired, validating only the signature and not the audience, confusing ID tokens with access tokens and using the deprecated implicit flow. Use the discovery document to avoid hard coded endpoints, log the reason for each token validation failure and test with a tool that decodes tokens, so issues are visible quickly. A short checklist reviewed at every integration prevents most security defects.

OIDC in microservice and API environments

In larger estates, tokens flow through gateways and services. An API gateway can validate access tokens centrally and pass trusted identity context to microservices, which then enforce fine grained permissions. This keeps token validation consistent and reduces the chance that one service skips a check. Combine it with API management policies for quotas and logging, and keep service to service calls on short lived machine credentials instead of reusing user tokens.

Plan for token lifetime and revocation. Short access tokens limit damage if one leaks, while refresh token rotation and session revocation endpoints let you cut off compromised sessions. Document which services accept which audiences and scopes, so new teams integrate correctly from day one.

Key takeaways

  • OpenID Connect adds authentication to OAuth 2.0 using a signed ID token.
  • Use the authorisation code flow with PKCE for web, mobile and single page apps.
  • Validate ID tokens fully and keep tokens short lived and protected.
  • OIDC is simpler and more API friendly than SAML, which still dominates legacy enterprise apps.
  • Use certified libraries and design authorisation separately from authentication.

Quick glossary

TermMeaning
ID tokenA JWT proving who authenticated
Access tokenA credential for APIs
PKCEProof key protecting the authorisation code flow
ClaimA piece of information about the user
Discovery documentA published list of OIDC endpoints and keys

Read next: What Is API Management? Lifecycle, Features, Tools · What Is a Message Queue? Patterns and Best Practices · What Is RabbitMQ? Exchanges, Queues and Use Cases

Frequently asked questions

What is OpenID Connect in simple terms?

It is a standard way for an application to confirm who a user is by relying on an identity provider, built on top of OAuth 2.0.

What is the difference between OAuth 2.0 and OpenID Connect?

OAuth 2.0 grants access to resources. OpenID Connect adds authentication, returning an ID token that identifies the user.

What is an ID token?

It is a signed JSON Web Token containing claims about the authentication event and the user, intended for the client application.

Which OIDC flow should I use?

Use the authorisation code flow with PKCE for web, mobile and single page applications. Avoid the implicit flow.

Is OpenID Connect better than SAML?

OIDC is lighter and better for modern apps and APIs, while SAML remains common in established enterprise applications. Many organisations support both.

Can I use OIDC for single sign-on?

Yes. With a shared identity provider, signing in once gives access to multiple OIDC enabled applications.

What does the openid scope do?

It signals an OIDC request, so the provider returns an ID token along with any other requested tokens.

How do I secure OIDC tokens?

Validate signature, issuer, audience, expiry and nonce, use short lifetimes, rotate refresh tokens and store tokens safely.

Was this guide helpful?Your answer helps us decide what to improve. It is not linked to you.

#what is openid connect#oidc vs oauth#openid connect flow#id token#oidc vs saml

About the author

Arjun Mehta

Integration Architect

Arjun designs and builds integration architecture connecting CRM, ERP, and custom systems, with a specific focus on API-led connectivity patterns using MuleSoft.

Integration & APIs (MuleSoftREST/Bulk APIs)

Ready to put AI and data to work?

Book a free consultation and leave with a plan, not a pitch.

Get a free consultationRequest quote