PKCE · public clients · token exchange

Charles Trinh — OAuth PKCE for Healthcare | Las Vegas, NV · Las Vegas, Nevada · Henderson · Clark County, Nevada · North Las Vegas, Nevada

A service card reading OAUTH PKCE — public clients bound to a verifier, not a secret
Charles Trinh — OAuth PKCE for Healthcare

PKCE is what makes an authorisation code flow safe for an app that cannot keep a secret — which is every mobile app and every browser-based client in a patient-facing product.

What this is

In the authorisation code flow the client receives a code and exchanges it for a token. A public client — a mobile app, a single-page app — cannot hold a client secret, so the exchange has to be bound to something else, or an attacker who intercepts the code can redeem it. PKCE binds the exchange to a verifier the client generated and kept, which the authorisation server checks at redemption.

The details decide whether the protection is real. The code challenge method must be S256 rather than plain. The verifier must be unpredictable and single-use. The redirect URI must be matched exactly rather than by prefix. Each of those is a small implementation choice, and each has been the cause of a real-world account takeover when it was done loosely.

Healthcare adds a consent surface that generic OAuth guidance ignores. The authorisation step is where the patient sees which app is asking for which scopes, and that screen is a regulated disclosure, not a UI detail. Its wording, its scope granularity and its record of what the patient agreed to all matter.

Token lifetime and refresh rotation are the operational half. A short access token with rotating refresh tokens limits the damage of a stolen token, but it also means the app must handle refresh failures gracefully — and an app that silently drops a patient to a login screen when a refresh fails will generate support tickets until someone loosens the token lifetime.

Mobile clients bring their own hazards: custom URL schemes can be claimed by another app, and a redirect that leaves the app can be intercepted. Universal links or app links, plus a strict redirect allow-list, are the mitigations, and they have to be tested on real devices rather than assumed from the platform documentation.Libraries are the quiet risk. A client library that defaults to the plain challenge method, caches tokens in a place other apps can read, or treats a refresh failure as a reason to re-prompt silently, will undo a careful server configuration. Reviewing the library's defaults is part of the work, not an afterthought.

How I do it

Review the flow end to end against the current best-practice profile: challenge method, verifier strength, single-use codes, exact redirect matching, and the binding of the token to the client that requested it.

Then the consent surface: scopes that map to what the app actually needs, wording a patient can understand, and a record of the grant that the patient can review and revoke later.

Finally the failure paths: expired code, reused code, mismatched verifier, revoked grant and failed refresh. Each must fail closed and produce a message the app can act on.

The client is tested as an attacker would: a second app claiming the redirect, a replayed code, a tampered verifier. Each case must fail closed and must produce an error the app can display rather than a blank screen.Tokens are treated as bearer credentials with a short life: stored in the platform keystore rather than in plain files, never logged, and rotated on a schedule. The tests assert that a stolen token expires before it can be useful and that a stolen refresh token cannot silently extend a session.

Artifacts you keep

  • An end-to-end flow review against the current best-practice profile
  • Scope design mapped to the app's actual data needs
  • A consent screen reviewed as a regulated disclosure
  • Failure-path tests: expired, reused, mismatched, revoked, refresh failure
  • Token lifetime and rotation policy with the app's handling documented

The four failures that actually get exploited

Redirect URI matched by prefix rather than exact string, which turns the authorisation server into an open redirect and therefore into a credential leak. State accepted without verification, which allows request forgery and, clinically, delivers a launch context intended for a different patient.

Token accepted at a resource server that is not its audience, which converts a scope mistake into a record disclosure. Refresh token reuse undetected, which means a stolen token store looks exactly like normal traffic.

Each has a one-hour test and a one-line fix. They persist because the happy path works and conformance testing does not probe them.

Scope enforcement at the data layer

Granting patient/Observation.read and trusting a patient identifier in the request is not authorisation. The granted scope and launch context have to reach the query, and the query has to enforce them.

If the check lives in the route handler and the fetch lives in a shared service, the check is decoration. An application changing one parameter reads a different patient, and the log records a legitimate request.

Write scopes need separate treatment: a write granted for convenience will be used for something the granter did not imagine, and the audit trail will name the application rather than the human.

Revocation and the token lifetime argument

Revocation that takes effect at the next refresh is not revocation from the member's perspective. They withdrew access and data kept flowing, which is indistinguishable from being ignored.

Fix it with a grant-version stamp checked on the resource path rather than a shorter lifetime. It fails safe, it is cheap, and it is testable in an afternoon: revoke mid-session and confirm the next request dies.

The same mechanism covers the case nobody plans for — a member revoking while a bulk export runs. The job should terminate, not complete.

The test sheet, in order

Four tests, run against production with a real client rather than a script, because the failures depend on browser behaviour that curl never reproduces.

Modify a redirect URI by one character and confirm rejection rather than a redirect. Send an authorisation request without state and confirm rejection rather than silent acceptance. Present a valid token to a resource server that is not its audience and confirm refusal. Replay a used refresh token and confirm the entire family is revoked rather than the single token.

Then revoke a grant mid-session and confirm the very next resource request fails. That fifth test is the one that separates a revocation mechanism from a revocation column, and it is the one most implementations fail while believing they pass.

What to publish so clients can behave

An accurate capability statement, an accurate smart-configuration document, the scopes you enforce with an example of each, and the error shapes with example responses. An application that receives an undocumented failure has no behaviour available to it except a support ticket.

Publish the rate limits too. An unpublished limit that is enforced is an outage with an explanation nobody has written down, and the member experiences it as the plan being broken.

Then test it yourself, with the documentation in front of you and no help. If a competent developer cannot complete the flow from what you published, the documentation is the defect and it will generate support tickets until it is fixed.

Proof

  • ONC (g)(10) self-test PASS, 317 of 317 subtests, April 2026 — public suite URL
  • 67 public hostnames, 51 serving, one AWS account
  • 104 clearinghouse enrolments across 53 jurisdictions
  • USCDI v7 proposal — Patient Digital Identity Credential — listed at isp.healthit.gov
  • SAM.gov UEI MVKQW9DKKGB8 · CAGE 20KM5 · NPI 1194645564
  • AWS Business Associate Addendum active since 18 August 2026

Where this work is delivered

Engagements run from Las Vegas and reach across the valley: clients in Las Vegas, NV; Las Vegas, Nevada; Henderson; Clark County, Nevada; and North Las Vegas, Nevada — plus remote delivery nationwide.

How an engagement runs

1. Trace one real case

Follow a single patient or claim end to end with a timestamp at every hop, before any document is written.

2. Written findings

A findings list naming the defect, the system, the owner and the date.

3. Monthly review

Review the list monthly and check whether the dates held.

Frequently asked

What is this service?

This page describes charles trinh — oauth pkce for healthcare — the scope, the failure modes it prevents and how the work is measured. It sits in the Identity and Consent category at trinh.io.

Where is the work delivered?

Engagements run from Las Vegas, Nevada across the valley — Las Vegas, Henderson, North Las Vegas, Spring Valley, Paradise, Winchester, Sunrise Manor, Enterprise, Summerlin, Clark County — and remotely anywhere in the United States. On-site work in the Las Vegas valley, remote delivery elsewhere.

What does it cost?

Standard rate $195 per hour, committed $165 per hour at twenty hours or more per week for three months or more; $1,600 standard day, $1,350 committed day. Scoped in writing before work starts, fixed fee where the deliverable is defined.

Who is Charles Trinh?

A technology architect in Las Vegas, Nevada, working in healthcare identity, consent and interoperability. Not a physician, not a medical practice, and not affiliated with any other Charles Trinh.

How does an engagement start?

With one trace of a real case and a written findings list naming the defect, the system, the owner and the date. The first call is twenty minutes and free: 702-559-3489.

Engagement

Scoped in writing before work starts; fixed fee where the deliverable is defined. First call is 20 minutes and free. 702-559-3489 · charles@trinh.io

Talk to Charles

Record

Profile

Healthcare technology architect working where federal regulation becomes production infrastructure. Built and operates a FHIR R4 clinical platform — SMART App Launch authorization server, patient and provider portals, SQLite — on a hardened single-host AWS estate of 67 public hostnames. The platform returned a self-test PASS on the ONC (g)(10) Standardized API test suite in April 2026, 317 of 317 subtests, publicly verifiable. Designed a consent architecture in which a permissioned ledger records patient grant, refusal and revocation as immutable events while all clinical data stays off-chain and encrypted per patient — no PHI on the ledger by design. Filed a proposed USCDI v7 data element with ONC on verifiable patient identity. Translates the Federal Register, HHS/CMS guidance and HITRUST requirements into architecture, controls and audit evidence.

Selected engineering scale

  • Self-managed estate of 67 public hostnames, 51 serving, on one AWS account.
  • FHIR R4 API with a SMART App Launch authorization server; patient and provider portals; an AI service layer; Hyperledger Fabric peer, orderer and CA; IPFS; a 337-table SQLite clinical store.
  • Two permissioned distributed ledgers in production, one operating a consent registry that records grant, refusal and revocation with no PHI on chain.
  • X12 005010 pipelines across eight transaction sets.
  • Designed, built, deployed and operated end to end by one person.

Credentials and standards work

  • Inferno (g)(10) self-test PASS, 317 of 317 subtests, April 2026 — the ONC Standardized API test suite. Standards validated: US Core 6.1.0, USCDI v3, SMART App Launch 2.0.0, Bulk Data 2.0.0. Public suite URL.
  • USCDI v7 public comment submission, April 2026 — proposed Patient Digital Identity Credential under the Provenance data class, listed publicly on the ONC Interoperability Standards Platform.
  • SAM.gov UEI MVKQW9DKKGB8 · CAGE 20KM5 · NPI 1194645564. AWS Business Associate Addendum active 18 August 2026.

Technical environment

AWS us-east-1 (compute, storage, messaging, SMS, email, voice) · Linux and systemd hardening · nginx · Fabric and EVM ledgers · FHIR R4 · X12 005010 · HL7 · SQLite · self-hosted mail, drive, search and monitoring · Git-based change control and CI release gates.

TRINH — Charles Trinh, technology architect
TRINH

Charles Trinh

Fractional CTO/CIO and Technology Architect — Healthcare Data, Identity & Regulated Infrastructure · Las Vegas, NV

Las Vegas, Nevada · US citizen · Fractional and project engagements

(702) 559-3489 Email Charles Trinh