Skip to main content

OAuth and OIDC Basics

Overview

OAuth 2.0, OAuth 2.1, referred to here as OAuth (Open Authorization), and OIDC (OpenID Connect) are open standards for authorization and authentication. They are the foundation for secure access across APIs, web, and mobile apps — enabling delegated and passwordless access.


OAuth Authorization Framework

OAuth 2.0 lets a user (resource owner) grant limited access to their resources (like files or APIs) to a client application, without sharing passwords.

Example: Allowing Slack to read your Google Calendar events without giving it your Google password.

OAuth 2.1 is an evolution of OAuth 2.0 that simplifies and secures the protocol by deprecating insecure features and recommending best practices.

The references to OAuth apply to OAuth 2.1 but can also be used with OAuth 2.0.

Key Roles

RoleDescription
Resource OwnerThe user who owns the data or resource.
ClientThe app requesting access on behalf of the user.
Authorization ServerIssues tokens after authenticating the user and client. IDaaS is the Authorization Server.
Resource ServerAPI or service that validates tokens and provides data. IDaaS issues tokens used by the Resource Server

Grant Types

Grants describe how clients obtain tokens.

Grant TypeDescriptionCommon Use Case
Authorization CodeExchanges an authorization code for tokens after user consent.Web and backend apps (secure, server-side).
Authorization Code with PKCE (Proof Key for Code Exchange)Variant of Authorization Code for public clients (no client secret).Mobile apps and SPAs.
Client CredentialsDirect app-to-app authorization without user interaction.Service APIs, microservices, M2M.
Refresh TokenObtains new access tokens without user re-login.Long-lived sessions.
Device CodeLets devices without browsers perform user login.TVs, IoT devices.
JWT IDaaSAn API-based variant of Authorization Code.Web and backend apps, Mobile apps, and SPAs.

Flow Types

Different app architectures use specific OAuth flows.

Flow TypeDescriptionUsed By
Authorization Code FlowClient redirects user to Authorization Server → gets code → exchanges for tokens.Web apps (secure backend).
Authorization Code Flow with PKCEAdds PKCE challenge/verifier to protect public clients from interception.Mobile and SPA apps.
Implicit Flow (OAuth 2.0 only)Tokens returned directly via browser redirect (no code exchange).Deprecated, formerly SPAs.
Client Credentials FlowNo user — client authenticates directly for API access.Daemons, backend services.
Device Authorization FlowUser logs in on a separate device to authorize.Smart TVs, consoles, IoT.
JWT IDaaS FlowAPI-based variant of Authorization Code providing IDaaS Authentication API capability.Consumer SSO, complex OIDC apps.

OIDC Authentication Layer

OIDC extends OAuth to add identity authentication.
While OAuth grants permission to resources, OIDC tells the client application who the user is.

Key Additions

OIDC ConceptDescription
ID TokenA JWT that contains verified user identity info (e.g., sub, email, name).
UserInfo EndpointREST endpoint returning user claims.
ScopesAdditions like openid, profile, email, etc.
ClaimsSpecific user attributes included in tokens.

Flow Types

OIDC FlowBased OnDescription
Authorization Code FlowOAuth Code FlowStandard web app login. Server exchanges code for id_token + access_token.
Authorization Code Flow with PKCEAuthorization Code + PKCESecure for mobile/native apps (no client secret needed).
Implicit FlowOAuth Implicit FlowReturns tokens directly via redirect (legacy).
Authenticated Implicit FlowOAuth Implicit FlowReturns tokens directly via redirect for authenticated requests such as Microsoft EAM (External Authentication Methods).
JWT IDaaS FlowOAuth JWT IDaaS FlowAPI-based login. Provides IDaaS Authentication API capability.

OAuth/OIDC Authentication Layer

OIDC can also be combined with OAuth to issue id tokens for clients applications and access tokens for resource servers. The id token tells the client application who the user is and the access token grants permission to resources.

Key Additions

OIDC ConceptDescription
UserInfo EndpointNot applicable.
ScopesOIDC based scopes can be associated with OAuth access tokens as well.
ClaimsOIDC based claims can be added to access tokens as well.

Flow Types

Same as OAuth Flow Types.


Examples Flows

OAuth Authorization Code Flow

  1. User signs in → redirected to the Authorization Server.
  2. Authorization Server authenticates (passwordless, passkey, etc.).
  3. User grants consent to the client.
  4. Client receives an authorization code.
  5. Client exchanges it for an Access Token.
  6. Client uses Access Token to access resource server APIs.

OIDC Authorization Code Flow

  1. User signs in → redirected to the Authorization Server.
  2. Authorization Server authenticates (passwordless, passkey, etc.).
  3. User grants consent to the client.
  4. Client receives an authorization code.
  5. Client exchanges it for an Access Token and ID Token.
  6. Client validates ID Token.
  7. Client uses Access Token to access UserInfo Endpoint APIs.

OAuth/OIDC Authorization Code Flow

  1. User signs in → redirected to the Authorization Server.
  2. Authorization Server authenticates (passwordless, passkey, etc.).
  3. User grants consent to the client.
  4. Client receives an authorization code.
  5. Client exchanges it for an Access Token and ID Token.
  6. Client validates ID Token.
  7. Client uses Access Token to access resource server APIs.

Example Response Token Sets

OAuth

{
"access_token": "eyWkr0i3pck...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "def50200a1..."
}

The access token is a JWT token used to access resource server.

OIDC

{
"access_token": "u3pgnmeis03r...",
"id_token": "eyJraWQiOiJ...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "def50200a1..."
}

The access token is a JWT token used to access resource server. The id token is a JWT token used to identify the authenticated user.

OAuth/OIDC

{
"access_token": "eyWkr0i3pck...",
"id_token": "eyJraWQiOiJ...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "def50200a1..."
}

The access token is a JWT token used to access resource server. The id token is a JWT token used to identify the authenticated user.


Example Tokens

OAuth/OIDC ID Token

{
"x5t": "mtMXOuqGEWrLh7YURswUhOPs6CI",
"kid": "200706313",
"typ": "JWT",
"alg": "RS256"
}

Payload

{
"jti": "3bb2e670-f5a5-477c-87e0-5d2841bcaad4",
"nonce": "k3ao4pwi302vsijf",
"sub": "user1",
"iss": "https://example.us.trustedauth.com/api/oidc",
"aud": "fcd612d3-79e6-4702-ba9d-90575125394f",
"iat": 1763664566,
"nbf": 1763664566,
"exp": 1763668166,
"locale": "en",
"tid": "3a4a1be8-3989-42b2-931b-deed82536152",
"auth_time": 1763664558,
"acr": "urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken",
"amr": ["OTP", "otp", "sms", "pop"],
"authenticators": ["NONE:OTP"],
"email": "user.one@example.com",
"given_name": "User",
"family_name": "One",
"name": "User One",
"nickname": "User1",
"groups_unique": ["2e90e388-f368-40e5-ab5a-2cf3c650eaa0", "7aa381e6-6834-4e66-b985-3ced99dad2cf"],
"groups": ["Auditor", "Help Desk"],
"favorite_color": "Blue"
}

OAuth/OIDC Access Token

Header

{
"x5t": "mtMXOuqGEWrLh7YURswUhOPs6CI",
"kid": "200706313",
"typ": "at+JWT",
"alg": "RS256"
}

Payload (lite)

The configuration for this access token has been enabled to include minimal user information and additional authorization server information in the token.

{
"jti": "2e6fc675-8983-413e-b52b-dc1b629f8575",
"sub": "user1",
"iss": "https://example.us.trustedauth.com/api/oidc",
"aud": "https://demo.com/marketplace",
"iat": 1763664566,
"nbf": 1763664566,
"exp": 1763664626,
"cid": "fcd612d3-79e6-4702-ba9d-90575125394f",
"scope": "view:tests view:claims view:flights view:profile view:visits fill:claims post:visits"
}

Payload (full)

note

The configuration for this access token has been enabled to include all user information as well as additional authorization server information in the token.

{
"jti": "2e6fc675-8983-413e-b52b-dc1b629f8575",
"sub": "user1",
"iss": "https://example.us.trustedauth.com/api/oidc",
"aud": "https://demo.com/marketplace",
"iat": 1763664566,
"nbf": 1763664566,
"exp": 1763664626,
"locale": "en",
"tid": "3a4a1be8-3989-42b2-931b-deed82536152",
"cid": "fcd612d3-79e6-4702-ba9d-90575125394f",
"app": "Client Engagement",
"auth_time": 1763664558,
"acr": "urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken",
"amr": ["OTP", "otp", "sms", "pop"],
"authenticators": ["NONE:OTP"],
"scope": "view:tests view:claims view:flights view:profile view:visits fill:claims post:visits",
"email": "user.one@example.com",
"given_name": "User",
"family_name": "One",
"name": "User One",
"nickname": "User1",
"groups_unique": ["2e90e388-f368-40e5-ab5a-2cf3c650eaa0", "7aa381e6-6834-4e66-b985-3ced99dad2cf"],
"groups": ["Auditor", "Help Desk"],
"favorite_color": "Blue"
}

Token Validation

OIDC ID Token

An OIDC client must validate the ID token. Checks must include:

  • ✅ Signature (using authorization server’s JWKS keys)
  • ✅ Issuer (iss) matches expected authorization server
  • ✅ Audience (aud) contains client ID
  • ✅ Expiration (exp) is valid
  • ✅ Not Before (nbf) is valid
  • ✅ Nonce (for replay protection)
  • ✅ (If Requested) Authentication Context Reference (acr) is valid
  • ✅ (If Requested) Authentication Time (auth_time) is valid

OAuth Access Token

A resource server or an API gateway protecting a resource server must validate the access token. Checks must include:

  • ✅ Signature (using authorization server’s JWKS keys)
  • ✅ Issuer (iss) matches expected authorization server
  • ✅ Audience (aud) contains the resource being accessed
  • ✅ Expiration (exp) is valid
  • ✅ Not Before (nbf) is valid
  • ✅ Scope (scope) contain the necessary scope permissions to access the requested resource
  • ✅ (Optional) Client ID (cid) is valid

Summary Table

ConceptOAuthOIDCOAuth/OIDC
PurposeAuthorization by Client Applications to Resource ServersAuthentication of users by Client ApplicationsAuthorization and Authentication
TokensAccess and Refresh for resource serversID, Access, and Refresh for client applicationsID, Access, and Refresh for client applications; Access and Refresh for resource servers
Scopesapi.read, api.writeopenid, profile, emailopenid, profile, email, api.read, api.write
FlowsCode, PKCE, Client Credentials, Device, JWT IDaaSCode, PKCE, Authn Implicit, JWT IDaaSCode, PKCE, Client Credentials, Device, JWT IDaaS
OutputAPI AccessAuthenticated IdentityAPI Access and Authenticated Identity

Best Practices

  • Always use Authorization Code with PKCE for mobile/web.
  • Avoid Implicit flows.
  • Use HTTPS everywhere.
  • Validate ID token claims properly.
  • Validate Access token claims properly.
  • Rotate and expire tokens regularly.
  • Use Refresh Tokens securely (bound to client or resource server).

References