Medplum access and refresh token lifetimes

Medplum access and refresh token lifetimes decide how long a sign-in lasts, how often users re-authenticate and what a stolen token can do. This page explains how to set them by application risk on a self-hosted deployment.

On this page

How Medplum access and refresh token lifetimes affect sessions

Set access and refresh token lifetimes per application, according to the risk each application carries, and confirm the default values and per-client override options in the Medplum authentication docs for the exact version you deploy. A clinician using a charting app, a patient using a portal and a back-end integration that moves data overnight do not present the same exposure, so a single global setting is rarely the right answer. Before you change anything, record which clients exist, who uses them and how long a stolen token would remain useful to an attacker.

An access token is the short-lived credential a client presents on each API call to Medplum. Because it travels with every request, its lifetime sets how long a copied token can be replayed without any further check. A refresh token is a longer-lived credential the client uses to obtain a new access token without asking the user to sign in again. This is what keeps a clinician signed in through a shift, and it is also the credential you most need to protect, because whoever holds it can keep minting access tokens until it expires or is revoked.

Offline access is the scope that tells the authorization server to issue a refresh token in the first place. Whether a given client requests it, and whether your deployment grants it, determines whether a session can outlive the browser or device that started it. Confirm how your deployed version names this scope, how refresh tokens are stored on the client side (browser storage, a secure backend or a mobile keychain) and what happens to existing refresh tokens when you change a lifetime. Those answers decide how idle sessions expire and whether a logout actually ends access everywhere.

How tokens move between the app, Medplum Auth and the FHIR API

The sequence starts with a browser or mobile app signing in through Medplum Auth and receiving an access token and a refresh token. The app then calls the FHIR API with the access token, which is where access token expiry is enforced. When the access token expires, the app presents the refresh token to Medplum Auth, where refresh token expiry and idle timeout apply. The stored refresh token is the exposure point to review, along with how logout ends the session. Confirm exact lifetime settings against Medplum's authentication documentation for your version.

Token flow from sign-in through refresh and logout, with lifetime enforcement points marked.

Medplum access and refresh token lifetimes by application risk

A clinician-facing web app is often opened on shared workstations in clinics, wards and nurse stations, where the next person at the keyboard may be a colleague, a contractor or someone without access to the chart. The main risk is an active session left behind on a machine that someone else can use, so the lifetime question is how long a browser session should stay usable after the last clinical action. Refresh behavior matters here as much as the access token, because a refresh token that quietly renews sessions can keep a forgotten login alive for much longer than the user expects.

  • Device sharing: Confirm whether workstations are shared by shift and whether users log out between patients or rely on automatic timeouts.
  • Idle behavior: Decide how long an idle session stays valid and whether activity in the app extends it.
  • Logout scope: Test whether logout clears the refresh token on the server, not only the browser state.
  • Re-authentication: Decide which actions, such as viewing sensitive records or signing orders, should require a fresh sign-in.
  • Upstream identity: If sign-in goes through an external provider, check how that provider's session length interacts with Medplum's.

Check that a session left idle on a shared workstation expires within the window your clinical governance sets, and that a logout on one machine does not leave other sessions valid.

Which token lifetime settings to review and when each fits

This table lists each configurable part of the Medplum token lifecycle, the decision it drives, the usability and exposure trade-off, and what to confirm for your deployed version. Read it as a checklist: start with the highest-risk applications, then adjust the settings that govern how long a session stays usable.

SettingDecision it drivesUsability vs. exposure trade-offConfirm in Medplum docs or ClientApplication settings
Access token lifetimeHow long a bearer token is accepted before the client must obtain a new oneShort lifetimes limit how long a stolen token works but add refresh traffic and can interrupt long clinical sessionsThe default value for your version, and whether it can be set per ClientApplication
Refresh token lifetimeHow long a client can get new access tokens without the user signing in againLonger lifetimes keep clinicians signed in across shifts but extend the window in which a leaked refresh token is usefulThe default refresh token lifetime, the maximum allowed, and whether the value is overridable per client
Offline access scopeWhether a client can receive a refresh token at all, for work that runs without a user presentOffline access supports background sync and batch jobs but creates a long-lived credential that outlives the user's sessionWhether the offline access scope is supported for your client type, and who may request it
Idle session behaviorWhat happens when a user stops interacting with an app but holds a valid refresh tokenIdle timeouts reduce exposure on shared workstations but interrupt charting and messaging if set too tightWhether Medplum enforces an idle timeout itself or relies on the client application, and where it is configured
Refresh token storage locationWhere the client keeps the refresh token: browser storage, server-side session or secure device storeServer-side storage keeps the token away from scripts in the browser but adds session infrastructure to run and monitorWhich storage model your client uses, and how the token is protected at rest on your servers and devices
Logout and revocation behaviorWhether signing out ends only the local session or also invalidates tokens already issuedFull revocation on logout protects shared devices but depends on the client calling the revocation path correctlyWhether logout revokes refresh tokens server-side, and how an administrator can revoke a user's active sessions
Interaction with SSO and MFAWhether lifetimes are set by Medplum or inherited from an external identity provider for federated usersProvider-side session rules can end access before Medplum lifetimes expire, which complicates troubleshootingHow federated sessions are refreshed or ended, and whether Medplum re-checks the external provider

How idle sessions and logout depend on token lifetimes

A short access token lifetime does not by itself end a session. While a valid refresh token exists, the client can usually request a new access token without the user signing in again, so the user's session continues past the access token's expiry. The refresh token lifetime, not the access token lifetime, usually decides how long a session stays alive. Before you shorten access tokens for a high-risk application, confirm how your Medplum deployment issues and renews refresh tokens for that ClientApplication, and whether any offline access scope gives the client a refresh token that outlives the user's normal session.

Idle timeout and refresh token lifetime interact in ways that are easy to miss. An idle timeout enforced in the application only works if the application discards tokens when the timer fires. If the refresh token remains valid on the server, anyone who obtains the stored token can still renew access, and offline access makes that window longer by design. Map each application to one rule: for example, a clinical workstation app that must end sessions after a period of inactivity needs both a short refresh token lifetime and client-side discard on idle. Confirm the exact values in your version's documentation and in your own configuration rather than relying on defaults.

Logout is effective only when it invalidates or discards both token types. On a shared workstation, clearing the access token from memory while leaving the refresh token in local storage lets the next user, or an attacker, obtain new access tokens. Test logout and idle expiry in your own environment: sign in on a shared device, log out, then replay the old refresh token against the token endpoint and confirm it is rejected. Repeat with an idle session that you leave past the configured limit. Record which token Medplum revokes on logout in the version you run, and check the Medplum authentication documentation for the current behavior before you write this into your runbook.

Setup sequence for token lifetimes on a self-hosted Medplum server

This sequence moves token lifetime decisions from default settings to a documented, tested policy for each client application, so that access and refresh behavior matches the risk of what each client can reach. Each step ends with a check you can record before moving on.

  1. Inventory every client application and its risk

    Start with a complete list of every ClientApplication in the self-hosted Medplum project, including patient-facing apps, clinician web apps, server-to-server integrations and internal tools. For each one, record who uses it, what data and resources its access policy exposes, whether it runs on shared workstations or personal devices, and how sensitive the data is. The security or compliance lead and the application owner should sign off on the risk rating. Done means every client has an owner and a risk level written down, with no unnamed clients left in the project.

  2. Record current lifetimes and offline access requests

    For each client, capture the access token lifetime and refresh token behavior that Medplum currently applies, and whether the client requests the offline access scope. Confirm the exact settings and defaults against the Medplum version your team has confirmed in the release notes, since settings and behavior can change between versions. Note any client that already holds long-lived refresh tokens. Done means you have a baseline table of observed values per client that you can compare against after changes.

  3. Decide a lifetime and offline policy per client

    Match each client's risk rating to a target access token lifetime, a refresh policy and a decision on whether offline access is allowed at all. Clients that run on shared devices or reach sensitive records usually warrant shorter lifetimes and no offline access unless a documented workflow needs it. Record the reasoning next to each decision so that a later reviewer can see why a client differs from its neighbors. Done means each client has one approved policy line, signed off by the owner and the security lead.

  4. Apply overrides in a non-production project

    Apply the chosen per-client overrides first in a non-production project on the same server version as production, changing one client at a time where practical. Keep a copy of the previous ClientApplication configuration so you can revert it. Confirm that the change saved and that the client still completes sign-in with its intended flow. Done means each override is applied in staging, the previous configuration is stored, and the client's sign-in works end to end.

  5. Verify issued tokens and expiry values

    Request real tokens from each non-production client using its actual flow, then decode the access token and inspect the expiry claims, along with the refresh token response. Compare the values with the policy line from the decision step. Also confirm that a client without the offline access scope does not receive a refresh token it should not have. Done means every client's token response matches its documented policy, and any mismatch is logged and resolved before testing continues.

  6. Test refresh, idle and logout behavior

    Test the user-facing behavior for each client: refresh after the access token expires, what happens after a period of inactivity, and whether logout revokes the session as expected. Run these tests on a shared workstation profile and on a personal device profile, since the same client can behave differently when a browser keeps state. Record what a user sees at each point. Done means the results for both device types are recorded, and any client that keeps a session after logout or forces an unexpected re-login has a fix or an accepted exception.

  7. Roll out to production and document the decision

    Apply the approved overrides to production during a planned change window, using the same steps that were proven in staging. Repeat the token check on one production client per flow to confirm the live behavior. Publish a short decision record that lists each client, its risk level, its lifetimes, its offline access status, the test evidence and the owner. Schedule a review tied to each Medplum upgrade, since the checks depend on the version in use. Done means production matches the record and the record is stored where audit reviewers can find it.

Refresh token storage and theft risks to plan for

A refresh token is a long-lived credential that can mint new access tokens without a password prompt, so where it sits and who can reach it matters as much as how long it lasts. The cards below cover the storage locations, shared-device exposure, leakage paths and lost-device scenarios that connect to the lifetimes you set for each Medplum client.

Browser storage and script access

Single-page apps may keep refresh tokens in browser storage, where any script running on the page can read them. A cross-site scripting flaw or a compromised front-end dependency can then export a token that keeps working after the user closes the tab. Decide whether your Medplum client needs refresh tokens in the browser at all, and if it does, confirm how your chosen client library stores them and whether it supports rotation. Check the current Medplum authentication docs for the refresh behavior of each client type.

Medplum auth docs

Mobile app secure storage

Mobile apps that hold refresh tokens should keep them in the platform keystore or keychain rather than in plain preferences files or app databases. Backups, rooted or jailbroken devices and debugging tools can expose weakly stored values. Confirm which storage API your mobile SDK uses, whether tokens are excluded from device backups, and how the app behaves when the keystore entry is invalidated after a passcode change.

Shared workstations and browser profiles

Clinics and shared floor workstations often leave a signed-in browser profile behind for the next shift. A refresh token persisted in that profile can let the next user resume a session that was never meant for them. Plan a short idle timeout, a sign-out step in the workflow, and a profile policy that clears site data at session end. Confirm in your own tests how long a Medplum session survives a closed browser and whether logout revokes the refresh token or only clears the local copy.

Token leakage through logs and support tools

Tokens often leak through request logs, error traces, analytics events and support screenshots, not through an attacker breaking the platform. A refresh token captured in a proxy log or a copied HAR file can be replayed until it expires or is revoked. Set up log redaction for the authorization and token request fields at your gateway, application and monitoring layers, and restrict who can export debugging data. Confirm which token endpoint parameters your logging stack records by default.

Revocation after a lost device

A lost or stolen phone or laptop with a valid offline refresh token can keep access open for as long as the token lifetime allows. Write a revocation procedure that identifies the affected client, ends its sessions and rotates any credentials it could have reached. Test the procedure before you need it, and confirm with Medplum how revocation of refresh tokens and existing sessions works on your deployment version, since the exact steps depend on the release you run.

Device management for offline access

Offline access scopes are only safe when the device holding the token is under management. Use mobile device management to enforce a screen lock, encryption and remote wipe before the app is allowed to store tokens. Limit offline access to roles that need it, and review the list of enrolled devices on a fixed schedule. Confirm with your MDM vendor which wipe actions clear app keychain data, because some clear the app but leave other storage behind.

How long should Medplum access and refresh tokens last?

How long should Medplum access tokens last for clinicians and patients?

There is no single correct number. Shorter access token lifetimes limit how long a stolen token stays useful, while longer ones reduce re-authentication for busy clinical staff. Set the value by application risk: a clinician charting on a shared workstation usually warrants a shorter window than a patient app on a personal phone, and both should be tested against real workflows. Start from the defaults in your deployed Medplum version, then confirm the access token and refresh token settings for each ClientApplication and any project-level options in your version's authentication documentation. Document the chosen values and the reasoning, since your compliance and security reviewers will ask for it.

Do Medplum apps need offline access and refresh tokens?

Only if the app must keep working or refresh sessions when the user is not actively signed in. Refresh tokens let a client obtain new access tokens without a fresh login, which suits long-running background tasks or mobile apps, but they also extend how long a session can live. Request offline access scopes only for clients that need them, and avoid granting them to browser-based staff applications by default. Confirm in your version how offline access is requested and granted, and test whether the client still works after an idle period.

What does a token lifetime change cost, and what drives the effort?

The cost comes from the time an engineer and a security reviewer spend mapping applications to risk tiers, changing client configuration, testing sign-in and refresh behavior, and writing the evidence your review needs. Effort rises with the number of ClientApplications, the number of identity providers involved, whether clients are browser, mobile or server-to-server, and how many clinical workflows depend on uninterrupted sessions. Ask any provider for a written quote that lists the applications in scope, the environments covered, the testing included and the documentation delivered. Any recurring costs, such as reviewing settings after upgrades, should be stated separately.

How long does a token lifetime review take?

The duration depends on how many applications and identity providers you have, how well documented your current settings are, and how many test environments must be checked. A review of one or two clients on a single identity provider takes much less time than a review across several clinical apps, patient portals and integrations. Ask for a timeline tied to a written scope, and confirm which settings must be validated in staging before any production change. No general duration applies, so treat any figure you are quoted as something to verify against your own inventory.

What does our team need to provide for a token lifetime review?

Expect to supply an inventory of ClientApplications, their owners, the users and workflows they serve, and the identity providers that feed sign-in. You also need access to a non-production Medplum environment, the current configuration, your session and logout requirements from clinical operations, and a named approver for each risk tier. Someone must be available to confirm how idle timeouts affect workflows such as charting or medication review. Without these inputs, a review tends to rely on assumptions that are hard to defend later.

Can our own team set Medplum token lifetimes without outside help?

Yes, if your engineers can read the authentication documentation for your deployed version, make changes in a staging environment and test sign-in, refresh and logout across every client. The harder part is usually the risk decision and the evidence, not the configuration change itself. Internal teams often underestimate the testing of idle sessions, multiple identity providers and automated clients that depend on refresh behavior. Whether you do it yourself or hire help, record each decision, the test results and the owner of future reviews.

How do token lifetime changes interact with upgrades and identity provider settings?

Token behavior can change between Medplum versions, so confirm the defaults and options in the version you run after every upgrade, and retest sessions as part of the upgrade plan. Self-hosted deployments must move through each minor version in sequence, which means token settings should be verified at each step rather than only at the end. Identity provider session lifetimes, such as those in Okta, Microsoft Entra ID or Auth0, also affect how long users stay signed in, so review both sides together. Check the current upgrade guidance before changing any setting.

What to confirm about Medplum token lifetimes before you set them

Token lifetimes in Medplum depend on the Medplum version you run, the client type, the login path and the identity provider behind it. Each item below is a question to answer in your own environment before you set a value, so the settings you choose match what the platform actually does.

Default lifetimes in your version

Ask which access and refresh token lifetimes your deployed Medplum version ships with, and whether those defaults differ for patients, practitioners and admin logins. Read the values from your running server configuration and your own test logins rather than from memory or older documentation. Record the values as your baseline so every later change can be measured against it.

Medplum auth docs

Lifetime options per client type

Ask which lifetime settings are available for each client type you use, such as a browser app, a ClientApplication for a backend service and a client used for server-to-server access. Some options may apply only to certain client types, so confirm each one on a test client before you assume a setting is supported across all of them.

Overrides for external identity logins

Ask whether a per-client lifetime override applies when a user signs in through an external identity provider, or whether the provider's own token lifetime governs that session. Test an external login end to end and check the expiry of the token Medplum issues. Do not assume a Medplum override shortens a session that the provider keeps alive.

Client credentials and machine tokens

Ask how lifetimes apply to tokens issued through client credentials, since system integrations often run unattended and may need short-lived tokens that are requested again on demand. Confirm whether a refresh token is issued in that flow at all. Verify that your integration can obtain a new token without manual steps before you shorten any lifetime.

Effect on tokens already issued

Ask whether a change to a lifetime applies to tokens issued before the change, or only to tokens issued afterward. Test this on a staging project with a token issued before the change and another issued after. Plan for existing sessions to end on their original schedule if the platform does not revoke them early.

Behavior after a server upgrade

Ask whether your upgrade path preserves lifetime settings, and whether any default changes in the target version. Medplum requires self-hosted upgrades to pass through each minor version in order, so check the lifetime behavior at every step. Record the setting before each upgrade and compare it afterward.

Upgrade guide

How DeployOpen scopes and delivers Medplum token lifetime work

DeployOpen plans, implements and documents Medplum access and refresh token lifetimes inside infrastructure you control, so each application's session length matches its risk. Engagements are fixed-scope, with the scope, deliverables and timeline agreed in writing before work starts.

How we scope

  • Inventory every ClientApplication and classify it by data sensitivity and user type
  • Record the access and refresh token lifetimes each client needs, with the reason for each value
  • Confirm which clients need offline access scopes and who approves them
  • Agree in writing which Medplum projects, environments and identity providers are in scope

How we build

  • Configure per-client token settings in a non-production Medplum environment first
  • Test idle timeout, refresh behavior and logout across web, mobile and server-to-server clients
  • Review how refresh tokens are stored in each application and remove any exposure we find
  • Run security tests against token issuance, revocation and reuse before production changes

How we hand over

  • Deliver a lifetime matrix listing each client, token type, duration and approved exception
  • Document the change procedure, owners and approval steps for future lifetime changes
  • Walk your engineering and security teams through test evidence and open risks
  • Record the configuration in your repository so reviewers can audit it

How we support

  • Retest token lifetime settings after each Medplum upgrade you schedule
  • Offer ongoing support, upgrades and continuous testing as a retainer
  • Review new clients and offline access requests against the agreed matrix
  • Confirm with your compliance team which evidence they need for your own assessments

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.