SMART on FHIR is the authorization framework that decides whether an app can actually get data out of an EHR. A FHIR API tells you what data looks like. SMART on FHIR tells you who is allowed to ask for it, under what context, and for how long. If you are building a patient portal feature, a clinician-facing app, a remote monitoring dashboard, or any tool that needs to read or write data in Epic, Cerner (Oracle Health), athenahealth, or another certified EHR, you will go through this framework whether you call it by name or not.
This article walks through how SMART App Launch actually works: the difference between an EHR launch and a standalone launch, what the authorization code flow looks like step by step, how scopes control access, and what changes when you are building a backend service instead of a user-facing app. It also covers the parts that trip up teams who have only read the marketing summary: PKCE requirements, token lifetime rules, and the ONC certification criterion that makes SMART support mandatory for most EHR vendors in the first place.
This is a deeper, more technical follow-up to our general guide to FHIR and EHR integration. If you have not worked with FHIR APIs at all yet, start there first. If you already understand what FHIR resources are and you are now trying to figure out how to actually authenticate against a live EHR sandbox, this is the layer you need.
What SMART on FHIR Solves
FHIR defines resources (Patient, Observation, MedicationRequest, and so on) and a REST API shape for working with them. It does not define how an app proves who it is or what it is allowed to see. That gap matters a lot in healthcare, where the same API endpoint might serve a patient looking at their own records, a clinician reviewing a panel of patients, and a backend analytics job pulling bulk data overnight. Each of those needs different permissions and a different trust model.
SMART App Launch, published by HL7 as an implementation guide on top of OAuth 2.0 and OpenID Connect, fills that gap. It standardizes:
- How an app discovers an EHR's authorization and token endpoints
- How a user grants an app access through a browser-based consent flow
- How access is scoped to a specific patient, encounter, or data type
- How backend services authenticate without a user present at all
- How tokens get refreshed, revoked, and inspected
Because it is built on OAuth 2.0, most of what you already know about authorization code flows and bearer tokens applies. The SMART-specific pieces are the launch context, the scope vocabulary, and a few security requirements that are stricter than plain OAuth.
EHR Launch vs. Standalone Launch
SMART supports two launch patterns, and picking the wrong one for your use case is a common early mistake.
EHR Launch
In an EHR launch, a clinician is already inside the EHR, looking at a specific patient's chart, and clicks a link or button that opens your app in a frame or new tab. The EHR calls your app's registered launch URL with two query parameters: iss, the FHIR server's base URL, and launch, an opaque token representing the current session context (which patient, which encounter, which user).
Your app uses iss to discover the authorization server, then starts the OAuth flow and requests the launch scope so it can redeem that context. This pattern fits apps meant to run embedded inside clinical workflows: a risk-scoring widget, a specialist referral tool, a documentation assistant.
Standalone Launch
In a standalone launch, the user opens your app directly, outside the EHR. There is no launch parameter to redeem. Instead, your app requests scopes like launch/patient to tell the authorization server it needs patient context, and the EHR's own UI (often a patient picker) collects that context during the consent step.
This pattern fits patient-facing apps: a portal feature, a remote monitoring companion app, a personal health record tool the patient opens from their phone, not from inside a clinical session.
Mixing these up usually shows up as a confusing bug: your app works fine in the sandbox you tested against but fails silently or throws scope errors against a real EHR, because the launch pattern your code assumes does not match how users actually reach the app in production.
The Authorization Flow, Step by Step
Once you know your launch pattern, the flow itself is a standard OAuth 2.0 authorization code grant with SMART-specific parameters layered on:
- Discovery. Your app fetches
{fhir-base-url}/.well-known/smart-configuration, a JSON document listing the authorization and token endpoints, supported scopes, and capabilities the server advertises. - Authorization request. Your app redirects the user's browser to the authorization endpoint with
response_type=code, yourclient_id, a registeredredirect_uri, the requestedscope, an unpredictablestatevalue, theaudparameter identifying the target FHIR server, and a PKCEcode_challenge. - User consent. The EHR authenticates the user (if not already authenticated) and presents a consent screen describing what the app wants access to.
- Redirect with code. On approval, the EHR redirects back to your
redirect_uriwith a short-lived authorizationcodeand the originalstatevalue, which your app must validate matches what it sent. - Token exchange. Your app posts the code, your
redirect_uri, and your PKCEcode_verifierto the token endpoint, and receives anaccess_token, atoken_typeofBearer, anexpires_invalue, the actually-grantedscope, and possibly arefresh_tokenand launch context values like apatientID. - API calls. Your app presents the access token as an
Authorization: Bearerheader on every subsequent FHIR API request.
Two details matter more than they look like they should. First, aud is not optional decoration: it tells the server which FHIR resource server the app intends to call, and it exists specifically to stop a valid token from being replayed against the wrong server. Second, the scope returned in the token response can be narrower than what you requested. The EHR, the organization's policy, or the user's consent choices can all reduce it. Your app has to handle a smaller grant gracefully, not assume it got everything it asked for.
PKCE Is Not Optional
Every SMART app, confidential or public, must implement Proof Key for Code Exchange (PKCE, RFC 7636). Your app generates a random code_verifier, derives a code_challenge from it using SHA-256, sends the challenge at authorization time, and presents the verifier at token exchange. SMART servers must support the S256 challenge method and must not accept the weaker plain method.
PKCE closes a specific attack: without it, an authorization code intercepted in transit (a misconfigured redirect, a logged URL, a compromised native app environment) could be redeemed by an attacker. With PKCE, the code is useless without the verifier, which never leaves your app until the token exchange request.
If you are integrating a vendor SDK or an identity platform that handles OAuth for you, verify it supports PKCE for this flow specifically. Some older OAuth libraries default to flows without PKCE unless configured otherwise.
Scopes: What They Actually Control
SMART scopes follow a structured syntax that combines a context, a resource type, and permitted interactions. A few examples:
patient/Observation.rs, read and search access to Observation resources within the launched patient's contextuser/MedicationRequest.rs, access scoped to whatever the authenticated clinician is permitted to see, not a single patientlaunch, redeems the EHR launch context handlelaunch/patient, requests that a standalone launch collect patient contextopenidandfhirUser, together return an identity token describing the authenticated useroffline_access, requests a refresh token so the app can maintain access without the user present
Two practical rules follow from this. Request the narrowest set of scopes your app actually needs, both because broader requests slow down app review and vetting with EHR vendors, and because a smaller blast radius matters if a token is ever compromised. And design your app to check the scope actually granted in the token response before assuming a feature will work, rather than discovering the gap when an API call returns a 403.
Backend Services: When There Is No User
Not every integration involves a person clicking through a consent screen. A nightly job pulling bulk FHIR exports for population health analytics, or a system-to-system feed between your platform and a health information exchange, needs to authenticate without anyone present to log in. SMART Backend Services, a separate part of the same implementation guide, covers this case. Instead of an authorization code flow, your backend service:
- Registers with the EHR ahead of time using an asymmetric key pair, giving the EHR your public key or a JWKS endpoint where it can be fetched
- At token request time, builds a signed JWT client assertion using its private key, asserting its own identity
- Posts that assertion to the token endpoint with
grant_type=client_credentialsand receives a short-lived access token scoped withsystem/scopes, for examplesystem/Patient.rs
No refresh tokens, no browser redirect, no user consent screen. This pattern is what underlies most production bulk-data and population-health integrations, and it is the one most teams discover too late, after they have already built a user-facing OAuth flow for a job that never involves a user.
Token Lifetime, Refresh, and Revocation
A few operational details deserve attention when you are building against this for real, not just a sandbox demo:
- Access tokens are generally short-lived, often an hour or less. Your app needs to handle expiration and refresh as a normal case, not an edge case.
- Refresh tokens, requested through
online_accessoroffline_accessscopes, let a session outlast the access token without re-prompting the user. When your app uses a refresh token, the server may issue a new one, and your app must store the replacement, not keep reusing the old value. - Users and organizations can revoke an app's access. Your app needs to handle a suddenly-invalid token as a real condition: fail cleanly, prompt re-authorization, do not retry indefinitely against a dead credential.
- Token responses must include cache-control headers preventing storage, and your app should store tokens in app-specific, not shared, storage.
Why This Is Not Optional for Most EHR Vendors
This is not just a best practice EHR vendors adopt voluntarily. ONC's certification criterion §170.315(g)(10), the Standardized API for Patient and Population Services, requires certified health IT to support SMART App Launch for both patient-facing standalone apps and clinician-facing EHR-launched apps, and to follow the SMART Backend Services approach for system-level access tied to bulk data export. The criterion also sets concrete operational requirements: refresh tokens for confidential apps and secured native apps must be valid for at least three months, repeat connections must not force re-authorization while a valid refresh token exists, and patient-directed revocation of an app's access must take effect within one hour. That is a big part of why this framework is worth understanding precisely rather than approximately: if you are integrating with a certified EHR, the vendor did not choose SMART as one option among several. They implemented it because federal certification required it, and the specific version and behavior they support is partly dictated by the same rule.
Common Mistakes Worth Planning Around
- Assuming sandbox behavior matches production. Vendor sandboxes (Epic's, Cerner's, athenahealth's) are good for development but sometimes relax scope enforcement or app vetting steps that production environments apply strictly.
- Treating
audas optional. Skipping it works in testing against a single server and breaks the moment your app needs to support multiple FHIR endpoints or an EHR tightens validation. - Building a user-facing flow for a backend job. If there is no person present to grant consent, you likely need SMART Backend Services, not a standard authorization code flow with a service account pretending to be a user.
- Under-scoping the app review process. Most EHR vendors require a formal app registration and review before production access, and that process takes real calendar time. Build it into your project timeline, not as an afterthought near launch.
- Ignoring the HIPAA layer on top. SMART on FHIR governs API-level authorization. It does not by itself make your application HIPAA compliant: compliance also depends on your organization's risk analysis, business associate agreements, audit logging, breach procedures, and the rest of your technical and administrative safeguards. This article is general technical information, not legal advice; confirm regulatory obligations with qualified compliance counsel.
Frequently Asked Questions
Is SMART on FHIR the same thing as FHIR?
No. FHIR defines the data model and REST API for clinical resources. SMART on FHIR is a separate implementation guide that defines how an app authenticates and gets authorized to call that API. You need both: FHIR to know what to ask for, SMART to be allowed to ask.
Do I need SMART on FHIR if I am only building an internal tool?
If your internal tool calls a certified EHR's FHIR API, in most cases yes, because that is how the EHR vendor exposes authorization. Purely internal systems that never touch the EHR's external API, and instead read from your own database or a data warehouse fed by other means, may not need it directly.
Can a mobile app safely store a client secret for SMART authorization?
No. Native and single-page apps should be registered as public clients, relying on PKCE rather than a client secret, because a secret embedded in distributed app code cannot be kept confidential. Reserve confidential client registration, with asymmetric or symmetric authentication, for server-side apps that can actually protect a secret.
What is the difference between user/ and patient/ scopes?
patient/ scopes limit access to data for the single patient established by the launch context. user/ scopes grant access based on whatever the authenticated user (typically a clinician) is permitted to see across their patient panel, which is a broader and different kind of grant.
How long does EHR vendor app approval usually take?
It varies by vendor and by whether you are targeting a sandbox, a limited pilot, or full production listing in an app marketplace, and timelines change over time, so confirm current requirements directly with the specific EHR vendor's developer program rather than assuming a fixed number.
Getting This Right the First Time
SMART on FHIR authorization is one of those pieces of healthcare software that looks like a solved problem from the outside and turns into a real engineering effort once you are implementing it against a specific EHR vendor's quirks, app review process, and production constraints. Getting the launch pattern, scopes, and token handling right the first time avoids a second round of EHR vendor review and a delayed go-live.
Sabyrix Technologies builds EHR and EMR integrations and broader healthcare software for US-based teams that need this layer done correctly, from authorization architecture through FHIR data handling. If you are planning an integration that needs to talk to Epic, Cerner, athenahealth, or another certified EHR, book a strategy call to talk through your specific launch pattern and timeline.