Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Offline access and refresh behavior

An OpenID Connect client asks for continued access explicitly, and the provider asks the person to agree. A refreshed ID token may come back later, but it describes the original sign-in, and a successful refresh never shows that the person is present or extends their session.

Asking for offline access

All domains, identifiers and tokens in these examples are fictional.

At 09:04 on 1 October, still signed in, Ava turns on the collage app's year-end collage: every December the app picks her best photos of the year and sends her a preview, long after she has closed her browser. The refresh token grant told a story like this from the OAuth side, with the printer's yearly calendar, and noted that a client asks for continued access with the offline_access scope. The collage app is an OpenID Connect relying party, so it asks.

Ava's sign-in at 09:00 asked only for openid profile email. It gave the collage app no access to her photos and no refresh token, which suited a sign-in. The year-end collage needs something else, so the app sends a separate authentication request to the return address it uses for photo connections:

https://auth.photos.example/authorize
  ?response_type=code
  &client_id=photo-collage
  &redirect_uri=https%3A%2F%2Fcollage.example%2Foauth%2Fcallback
  &scope=openid%20photos.read%20offline_access
  &prompt=consent
  &state=demo-attempt-8
  &nonce=demo-nonce-8
  &code_challenge=kPeoXcI0Ujq4KQcqIPlQawjpjjUu9V-tXHYDUACSnNM
  &code_challenge_method=S256

The offline_access scope asks for a refresh token that keeps working while Ava is away. OpenID Connect defines it narrowly, as a refresh token that can obtain access to her UserInfo endpoint even when she isn't present, but its consent rules speak of offline access to whatever resources are requested. Providers commonly treat it as the request for a refresh token covering the whole grant, and the photo service does: the refresh token it issues here will obtain photos.read access tokens in December. Including openid makes this an OpenID Connect request, so an ID token comes back as well.

prompt=consent asks the photo service to show Ava a consent screen, even though she has approved the collage app before. The specification requires it alongside offline access unless the provider has some other established basis for granting it, and it requires the provider to obtain her consent before returning a refresh token for offline use. An approval she gave earlier, for a sign-in, isn't necessarily enough. An application that can act while she is away deserves a deliberate decision, and the provider should make the long-term access clear:

Photo Collage would like to:
  View your photos
  Keep this access when you are not using Photo Collage

If the collage app left out prompt=consent and the photo service had no other basis for offline access, the specification tells the provider to ignore the offline_access request rather than refuse it. The authorization would succeed without a refresh token for offline use. A provider's own policy can also withhold refresh tokens from a client. So the app checks what the token response contains, and if no refresh token arrives, it tells Ava now that the year-end collage can't be set up, rather than discovering the problem in December.

Ava approves, and the token response looks familiar:

{
  "access_token": "demo-access-token-8",
  "token_type": "Bearer",
  "expires_in": 600,
  "refresh_token": "demo-refresh-token-3",
  "scope": "openid photos.read offline_access",
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InBob3Rvcy1ycy0yMDI2LTA5IiwidHlwIjoiSldUIn0..."
}

The ID token is shortened here. The collage app validates it as it validated her sign-in, against demo-nonce-8 this time, and records that the connection belongs to user-2048, the photo account she signs in with. The refresh token goes into the connection record that Server-rendered web applications described, tied to account 8812 rather than to the session that created it.

Refreshing in OIDC

On 1 December at 09:00, the year-end collage job sends demo-refresh-token-3 to the token endpoint. The request is exactly the one from The refresh token grant: the grant type, the refresh token and the app's client authentication. OpenID Connect adds nothing to it. The response adds one field:

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store

{
  "access_token": "demo-access-token-9",
  "token_type": "Bearer",
  "expires_in": 600,
  "refresh_token": "demo-refresh-token-4",
  "scope": "openid photos.read offline_access",
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InBob3Rvcy1ycy0yMDI2LTA5IiwidHlwIjoiSldUIn0..."
}

A provider may leave the ID token out of a refresh response, so the collage app must not depend on getting one. When one is present, OpenID Connect restricts what it may say. Here are the claims of the December token beside those of the ID token from October's authorization:

The October and December ID tokens, claim by claim
ClaimOctober, from the authorizationDecember, from the refresh
isshttps://auth.photos.exampleThe same
subuser-2048The same
audphoto-collageThe same
iat1790845440 (1 October, 09:04:00)1796115600 (1 December, 09:00:00)
exp1790845740 (1 October, 09:09:00)1796115900 (1 December, 09:05:00)
auth_time1790845185 (1 October, 08:59:45)The same
noncedemo-nonce-8Absent

The identity claims can't move. iss, sub and aud must match the ID token from the original authentication, so a refresh can never produce a token about a different person or for a different client. iat and exp are new, because this is a new token with its own short lifetime.

auth_time doesn't move either, and it matters most. It must still give the time of the original authentication, 08:59:45 on 1 October, not the time of the refresh. Notice that the October value is already earlier than that token's iat. When Ava turned on the year-end collage, the photo service asked for her consent but didn't ask her to authenticate again, because its session from her sign-in four minutes earlier was still running. No one authenticated in December at all. The token is new, but the authentication it describes is two months old.

The nonce is gone. A nonce ties an ID token to the authentication request that asked for it, and in December there was no authentication request, only a back-channel call from the app's server. The specification says a refreshed ID token should not contain one, and if it does, the value must be the original's.

So the collage app checks a refreshed ID token against the connection it already holds, after validating its signature and lifetime as usual. The issuer, subject and audience must be the ones it recorded in October, auth_time must still say 08:59:45 on 1 October, and a nonce, if one appears at all, must be demo-nonce-8. If anything else comes back, the app doesn't use the new token, and it marks the connection for someone to look at. When the response carries no ID token, nothing is wrong: the connection already knows whose it is from the token it validated in October, and the access token is what fetches the photos.

Refresh is not presence

The December refresh proves that this authorization remains usable and that the collage app can authenticate as the client. It doesn't prove that someone is now at a browser, that the provider session is still open, or that the person has just authenticated. A new iat is not a new auth_time.

Ava approves, 1 October

Who took part
Ava, her browser, photos
Person at a browser
Yes
iat
1 October, 09:04
auth_time
1 October, 08:59:45
Starts a session
Could: she is there

Ava was there

Refresh, 1 December

Who took part
App server, photos
Person at a browser
Not shown
iat
1 December, 09:00
auth_time
1 October, 08:59:45
Starts a session
No

The grant is still usable

Session renewed from a refresh

Who took part
App server, photos
Person at a browser
Whoever has the cookie
iat
New
auth_time
1 October, 08:59:45
Starts a session
Would, wrongly

The absolute timeout means nothing

A new iat is not a new auth_time.

The sign-in, the December refresh, and the shortcut of renewing an expired session from a refresh. Only the sign-in had Ava at a browser, so only the sign-in may start a session.

That makes one shortcut tempting and wrong. Ava's collage app session reaches its absolute deadline on 8 October. An app that wanted to keep her signed in longer could notice the expired session, refresh the year-end connection for account 8812, and treat the new ID token as a new sign-in. The token is genuine and names her, so this looks harmless. But the refresh involved only the app's server and the photo service, never Ava or her browser. Whoever presented the expired cookie, perhaps someone at a library computer she forgot to sign out of, would get a fresh session. The absolute timeout would stop meaning anything, and the account would stay open as long as the refresh token family lasts, which Refresh tokens and rotation set at two years.

So the collage app doesn't renew an expired session from the year-end connection. When Ava's session ends, her next visit starts a new sign-in, with fresh state, nonce and PKCE values. The photo service may answer straight from its own session or ask her to sign in, and the app then applies its own rules about how recent that sign-in must be. Another application might choose a longer session than the collage app does. What none should do is treat a refresh, made by a server or by a browser app, as the person coming back.

The independence runs the other way too. A refresh that fails with invalid_grant means the connection needs Ava to reconnect. It doesn't sign her out of the collage app, any more than signing out of the app cancels the year-end collage. Nor do refresh results reveal her photo service session. Current security guidance allows a provider to revoke refresh tokens when someone signs out of it, while offline access exists so that a grant can outlast that person's sessions there. Which the photo service does is its own policy.

When the collage app genuinely needs to know whether Ava is present, the reliable way to find out is to send her browser to the photo service with an authentication request and see what comes back.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

The collage app requests offline_access but leaves out prompt=consent, and the photo service has no other basis for granting offline access. What should the photo service do? 1 of 3

Choose one answer.

Ava's collage app session reaches its absolute deadline on 8 October. That morning the year-end connection refreshes and returns a new ID token for user-2048. What should the app do about her expired session? 2 of 3

Choose one answer.

In December a refresh returns an ID token whose sub matches but whose auth_time says 1 December. The October token said 1 October, 08:59:45. What should the collage app do? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity