Resources · 43

OAuth and OpenID Connect: verify an integration end to end

Separate sign-in, delegation and data permissions, then test redirects, tokens, sessions and revocation.

· 9 min

Fictional empty identity verification room with two security keys, blank card and burgundy dossier AI-generated editorial illustration

What this guide helps achieve

  • Separate identity from authorisation
  • Reject unintended redirects and tokens
  • Test denials as carefully as successes
  • Verify access removal after departure or incident

Quick check

  • Which provider and issuer are expected?
  • Is the redirect URI registered precisely?
  • Is an ID token wrongly being used as an access token?
  • Does each resource check ownership?
  • What access survives revocation?

Step-by-step method

  1. 01

    Draw the deployed flow

    Identify public or confidential client, browser, authorisation server, API and OIDC provider. Record where codes and tokens travel, who stores them and which roles are granted. A sales diagram does not establish the actual deployment.

    Deliverable: flow, trust boundaries and component owners.

  2. 02

    Check the sign-in transaction

    Use the code flow with PKCE appropriate to the client. Check S256, transaction binding, registered redirects and protection against forged requests. Test an unexpected URI, incorrect verifier, replayed code and unexpected issuer. RFC 9700 separates requirements and recommendations by client type.

    Deliverable: allowed and denied test results.

  3. 03

    Validate the right token

    The API validates its access token according to format and provider rules: signature or introspection, issuer, audience, expiry and permissions. The OIDC client separately validates the identity token. A valid signature does not establish that the token belongs to this API.

    Deliverable: validation contract and audience and expiry tests.

  4. 04

    Check business permissions

    Test an object owned by another account, a lower role, private field and administrative operation. A scope or authenticated gateway does not replace server-side checks on the requested resource. Use authorised test accounts and data.

    Deliverable: role, object, operation and expected-denial matrix.

  5. 05

    Exercise expiry and revocation

    Separate local session, provider session, access token and refresh token. Test departure, lost device, role change, signing-key rotation and provider outage. Document residual access time instead of assuming that sign-out immediately revokes everything.

    Deliverable: access-removal timeline and exceptions.

  6. 06

    Observe without exposing secrets

    Log transaction reference, validation decision, error category and configuration version. Exclude codes, tokens and secrets. Prepare diagnosis, integration shutdown and rollback to a validated configuration; replay tests after provider changes.

    Deliverable: operating procedure and regression checks.

Proposed acceptance scenarios

Fictional scenarios to adapt in an authorised environment. They describe no client result or certification.

Fictional situationSuggested checkEvidence to retain
A signed-in account A requests a document reserved for account B.Check that the API refuses access even when login and the token are valid for A. Authentication does not establish object permission.Service version, roles, fictional identifiers, expected result and observed response; no raw token.
A role is removed while a session and access token still exist.Observe remaining access under the deployed session and validation contract. Record timing and the actual control without promising universal instant revocation.Removal timeline, tested paths, session state and corrective decision.

Worked example

Illustrative situation

Illustrative situation: two clients use one identity provider. A token valid for the first is presented to the second client’s API.

Decision and expected evidence

The API rejects the wrong audience, records a token-free trace and returns no data. The denial becomes a regression test.

Distinguish the mechanisms

MechanismPurposeCheck or limitation
OAuth 2.0Delegate resource accessServer-side object permissions
OpenID ConnectEstablish identity through a validated ID tokenIssuer, audience and transaction validation
Application sessionMaintain application sign-inExpiry, invalidation and session protection

Management indicators

IndicatorWhat it measuresFirst action
Correct denialsForbidden cases actually blockedFix every unexpected acceptance
Revocation delayTime until relevant access disappearsCheck sessions and tokens separately
Validation failuresRejections by cause and versionSeparate attacks from configuration errors

Common pitfalls

  • Confusing authentication with authorisation
  • Accepting any audience after checking the signature
  • Registering broad redirect URIs
  • Logging tokens for easier debugging

Frequently asked questions

Does PKCE replace every control?

No. It protects the code exchange in the intended flow; token validation, redirects, business authorisation and sessions still need checking.

Is a JWT a permission?

JWT is a format. Claims become usable only after validation and application of your API rules.

Should validation be built from scratch?

Prefer a maintained library and provider documentation, then test your configuration. A correct library can still be configured incorrectly.

What evidence makes a verification useful?

Keep account context, expected roles, requested object and API responses. Successful login does not establish correct rights on every resource; acceptance logs must contain no session secret.

OAuth/OIDC: audience and access

Which token belongs to which recipient? A testable validation contract

A secure OAuth/OIDC integration connects each token to its purpose, issuer and intended recipient. An ID token tells the OIDC client about authentication; an access token is presented to a protected resource. Successful sign-in alone does not authorise a read, a change or an AI agent’s tool call.

This reference covers a specific profile: an API consuming JWT access tokens under RFC 9068. OAuth 2.0 does not require every access token to use JWT. Clients must treat their access tokens as opaque; the resource server owns the validation contract. The examples below are fictional, with no secret or usable signature.

Where codes and tokens belong
Where codes and tokens belong Four independent rows show the recipients: code to token endpoint, ID token to OIDC client, access token to API, refresh token to token endpoint. This is not the full exchange sequence. Code → Token endpoint Transaction-bound exchange ID token → OIDC client Identity and client_id audience Access token → API / resource Check audience and permissions Refresh token → Token endpoint Renewal, not an API call Distinct destinations · conceptual map, not a network sequence

Four objects with distinct purposes

Four objects with distinct purposes
ObjectRecipient and purposeBoundary to retain
Authorisation codeAuthorisation server token endpoint: redeem the code within the intended transaction.The code is not an API permission; check binding to the client, redirect and PKCE.
ID tokenOIDC client: validate identity and transaction; aud contains its client_id.Do not reuse it as an API access credential; apply the OIDC rules for the relevant flow.
Access tokenResource server: access within the grant; its audience identifies the intended resource.Validate the token, then operation and object permissions. The client must not depend on its internal content.
Refresh tokenAuthorisation server token endpoint: obtain new access tokens.Do not send it to the resource server; its lifecycle differs from the local session.

Eight controls for the validation contract

Eight controls for the validation contract
ControlRule and scopeEvidence without tokens
Profile and typFor RFC 9068, check typ = at+jwt or application/at+jwt. Other profiles need their own rules; “any signed JWT” is too broad a contract.Configured profile and a rejected ID/access token confusion case.
Algorithm and keysVerify the signature with the expected issuer’s keys and algorithms allowed by configuration. RFC 9068 excludes alg = none; a received value does not set policy by itself.Cryptographic policy version and result, with no secret material.
Issuer issCompare exactly with the expected issuer. A similar host, path or suffix does not establish trust.Configuration reference and issuer_mismatch reason.
Audience audThe expected recipient must appear in aud. An audience array is possible; finding the recipient does not replace other checks.Expected resource and a test using a token intended for another API.
Expiry expCurrent time must precede exp; any small clock leeway is an explicit policy. The teaching fixture uses zero seconds of leeway.Test clock, configured leeway and an exercised expiry boundary.
Scopes and objectBind each scope to the resource and operation. Then check ownership, tenant and business policy on the server. RFC 9068 does not define all this authorisation.Action, test object, applied rule and a cross-tenant denial.
OIDC transaction and PKCEIf nonce was sent, verify its presence and equality in the ID token. RFC 9700 requires PKCE for public clients and recommends it for confidential clients; bind the challenge to the transaction, with S256 recommended.Wrong nonce, replayed code and wrong code_verifier tests in the authorised flow.
Access lifetime and removalSeparate access-token expiry, renewal and application session. RFC 9700 requires sender constraint or rotation to detect refresh-token replay for public clients.Residual access timeline, user departure and an exercised revocation procedure.
Read fictional claims without treating them as proof

Teaching clock: 2026-10-22 at 10:00:00 UTC. The JSON contains a readable header and claims only; no signed JWT serialization is supplied. exp is 10:05:00 UTC and iat is 09:59:00 UTC. The .example domains and identifiers belong solely to this scenario.

{
    "header": {
        "typ": "at+jwt",
        "alg": "RS256",
        "kid": "training-key-01"
    },
    "claims": {
        "iss": "https://identity.example/",
        "sub": "training-subject-17",
        "aud": "https://api.example/evidence",
        "exp": 1792663500,
        "iat": 1792663140,
        "jti": "training-event-001",
        "client_id": "training-console",
        "scope": "evidence:read"
    }
}

Decoding JSON does not validate a signature or establish trust in keys. Where stated, cryptography is an exercise assumption, never a check performed by this page. The profile also has required claims including sub, client_id, iat and jti: the eight-control table is not a complete validator. A subject does not necessarily identify a person; jti alone does not implement replay protection.

Ten review cases: decision, limit and expected evidence

01 · Token intended for the API: continue to business checks

Situation: iss, aud, typ and exp match the fictional contract; evidence:read is present. Signature verification is assumed solely for the exercise.

Decision: continue to operation and object checks, without automatically declaring “access allowed”. Expected evidence: business rule and test object reviewed separately.

02 · Assumed correct signature, wrong audience

Change: aud targets https://api.example/billing rather than the evidence resource. Other assumptions remain the same.

Decision: reject this token for this API. A correct signature does not change its recipient. Expected evidence: no resource content returned and a token-free audience failure record.

03 · Different issuer with plausible claims

Change: iss is https://other-identity.example/. An HTTPS URL does not make it equivalent to the configured issuer.

Decision: reject the issuer match. Expected evidence: exact comparison with https://identity.example/ and a regression test.

04 · Expiry reached at the exact second

Change: exp equals the test clock, 10:00:00 UTC, with zero seconds of leeway in this fixture.

Decision: reject as expired. “Now is before exp” is false at equality; this example does not establish a universal clock policy. Expected evidence: tests before, at and after the boundary under the real policy.

05 · ID token presented as an access token

Change: a fictional ID token has typ = JWT and aud = training-console. It targets the OIDC client.

Decision: reject it as an RFC 9068 JWT access token. Validating it at the OIDC client does not turn it into an access token. Expected evidence: separate validation rules for each token type.

06 · Write scope presented for a read operation

Change: scope is evidence:write while the call requires evidence:read.

Decision: deny the read under the exercise policy, which defines no write → read implication. Scope names and relationships belong to the contract. Expected evidence: an explicit operation/scope matrix, without inferring permissions from names.

07 · Readable JSON, unverified cryptography

Situation: the JSON is readable and values appear to match, but cryptographic validation and trusted keys are not established.

Decision: stop acceptance; the state is unverified. Expected evidence: configured library output and trust-contract checks. Reading claims alone must not release protected data.

08 · Correct token, another tenant’s object

Situation: test token checks are assumed to pass. The requested object belongs to another tenant and business policy denies this read.

Decision: deny the object. evidence:read does not grant access to every account’s evidence. Expected evidence: server-side cross-tenant test and no leakage through content or returned fields.

09 · Audience array containing the expected resource

Change: aud contains https://api.example/evidence and https://api.example/archive. The expected resource is listed.

Decision: this audience check can pass; continue all other checks. An array is not a wildcard. Expected evidence: scopes remain meaningful for the resource, with no ambiguous grant.

10 · ID token nonce differs from the transaction

Separate OIDC transaction, outside the API cases: sent nonce = training-transaction-A; received nonce = training-transaction-B.

Decision: reject the ID token for this transaction under OIDC Core §3.1.3.7. This does not replace PKCE or API rules. Expected evidence: compare with the original transaction and test missing nonce when one was sent.

Six useful acceptance-review records

  • Map clients, issuers, APIs and expected audiences, with an owner for each boundary.
  • Versioned validation contract: format, libraries, trusted keys, algorithms and clock leeway.
  • Action, scope, tenant and object matrix; state denials and the permission implications actually defined.
  • Synthetic fixtures, a fixed clock, negative variants and observed results in the authorised environment.
  • Separate session, access-token and refresh-token timelines during departure, revocation and provider outage.
  • Redacted log: internal transaction reference, policy version, decision reason and date; exclude tokens, codes and secrets.

Primary sources and reading scope

Sources reviewed on

Official references

References consulted: . The method and worksheet propose checks to adapt to your context; they do not constitute certification.