Skip to content
Workforce IdentityMarkdown

Choose online or offline access

Which app access ends when the user signs out or their session times out, and which keeps working while they're away.

APIOpenID Connect Core 1.0

Every grant to an app is either online, tied to the user’s session, or offline, kept while the user is away. Online access is the safer default: closing the session closes everything the user gave apps along the way. Offline access is for apps that genuinely work while the user is away, such as a nightly sync, and the user always sees and agrees to it.

Online (the default)Offline
Asked for withany scopes without offline_accessoffline_access
Ends when they sign out, or the session times outYes, everywhere at onceNo
Access tokens lastno longer than the sessiontheir normal lifetime
Consentas usualalways asked, every time it is requested
Ends whenthe session ends, or the refresh tokens run outthe refresh tokens run out, or the user removes the app

Before you start:

  • Who can do it: a realm administrator, in a group that holds RealmOwner (Delegated administration). RealmViewer can read the settings but not change them.
  • Where: today this is done through the API; Call the API shows how to get $CVYUH_SESSION.
  • First: have the client ID of each app that should get offline access.
  1. Offline access is offered by default: the realm’s scopes include offline_access. To offer only online access, read the realm’s list with GET https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings, and send it back without offline_access:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "scopes": ["…existing scopes, without offline_access"] }'

    The list you send replaces the realm’s whole list, so keep every other scope in it.

  2. Let an app ask for offline access: read the client with GET https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/<client-id>, and send its scopes back with offline_access added:

    Terminal window
    curl -X PATCH 'https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/<client-id>' \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "scopes": ["…existing scopes", "offline_access"] }'
  3. Set how long sessions last, and so how long online access lasts. These are the defaults, two hours at most and 30 idle minutes:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/sessionSettings/sessionSettings \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "maxSessionMinutes": 120, "maxIdleMinutes": 30 }'
  • Online: nothing special for the user; signing out ends the app’s access too. After the session ends, the app’s refresh is refused and its access token reads inactive, so it sends the user to sign in again.
  • Offline: the consent page says the app asks for access while the user is away, every time it asks. The app’s refresh keeps working until the refresh lifetime runs out.

Sign in to an app with online access, then sign out of the realm. The app’s next refresh is refused.

For an app with offline access, the token response carries a refresh_token, and the user’s TOKEN_ISSUED record shows offline_access among the granted scopes. Find it in Audit → Authentication in the dashboard.

SymptomCauseFix
No refresh token for an app that asked for offline_accessThe realm’s or the client’s scopes lack it, the client lacks refresh_token in grantTypes, or the user didn’t allow itCheck steps 1 and 2; the user must click Allow
The consent page shows every timeOffline access is always asked for, by designAsk for offline_access only when the app needs it
An app keeps working after the user signs outIt holds offline accessRevoke its grant, or the user removes it on Authorized Apps

Send the client’s scopes back without offline_access, so it can’t ask again. Offline grants already made last until their refresh tokens run out; end them sooner by revoking the refresh token (Revocation), or the user removes the app.