Updated
Sessions and tokens
This page covers what happens after the first sign-in: how a person signs out, how to force or forbid the sign-in screen, how long each token and session lives, how refresh tokens rotate, when users see a consent screen and where the email address is. The addresses and ids are made up; take real endpoints from the tenant's discovery document.
Two sessions: yours and Algizian's
Signing a person in creates a session at Algizian, on the sign-in host of the tenant, kept in a host-only cookie (__Host-ag_session) for 8 hours. Your app has its own session on top of that, built from the tokens. Ending your app's session does not end Algizian's: the next /authorize finds the session and sends the browser straight back with a code, without showing a screen. That is single sign-on working as designed, not a broken sign-out. To end Algizian's session as well, send the browser to the logout endpoint.
The session belongs to one sign-in host. A tenant that also serves a custom domain has a separate session on each host.
Sign out
The end_session_endpoint in the discovery document is https://<sign-in host>/logout. Send the browser there with a plain GET (a redirect, not a background request, because it works on the browser's cookie):
https://acme-games.algizian.com/logout
?client_id=c_8f3k2m9x
&post_logout_redirect_uri=https%3A%2F%2Fapp.example.com%2Fsigned-out
&state=<STATE>
- It ends the Algizian session of that host (the stored session and the cookie). It also works when there is no session.
- With
client_idand apost_logout_redirect_uri, the browser is redirected back to your address, with yourstateadded when you sent one. The address is honoured only when it has no fragment and its origin (scheme, host and port) equals the origin of one of the redirect addresses registered for that client. There is no separate list of logout addresses andid_token_hintis not read. In every other case the person sees a "You are signed out" page and stays there. - It does not revoke refresh tokens and does not shorten tokens already issued: send the refresh token to
/revokeas well (refresh tokens); access tokens expire on their own within 10 minutes. - It does not sign the person out of Google, Microsoft or Apple. The next sign-in shows the Algizian sign-in screen, and the provider may sign the person in silently if they are still signed in there.
Forcing or forbidding the sign-in screen
/authorize reads the prompt parameter:
prompt=loginignores the existing session and shows the sign-in screen. After the sign-in a new session is created.prompt=nonenever shows a screen. With a valid session and nothing to ask, you get a code. Otherwise the browser returns to your redirect address witherror=login_required(no session) orerror=consent_required(session, but the person has not consented to this client and scope yet), plus yourstateandiss.
Nothing else is supported. select_account and consent as prompt values, combined values such as login consent, and the parameters max_age, id_token_hint, login_hint, acr_values and ui_locales are ignored, not rejected: the normal flow runs. To check how fresh a sign-in is, read auth_time in the ID token (the moment the session was created; a refresh token keeps the original value) and send the person back with prompt=login when it is too old.
Lifetimes
| What | Lives | Notes |
|---|---|---|
| Authorization code | 60 seconds | Single use; bound to the client, the redirect address and the PKCE challenge. |
| Access token | 10 minutes | A signed JWT; there is no revocation list, it expires on its own. |
| ID token | 1 hour | A signed JWT for your client. |
| Algizian session | 8 hours | Fixed from sign-in, not extended by activity. Ended by /logout. |
| Refresh token | 30 days | Counted from the moment it was issued; each use issues a new one. At most 180 days after the original sign-in, then the person signs in again. |
Signing keys are covered in Concepts.
Refresh tokens
A refresh token is issued when the client allows the refresh_token grant (the default); the offline_access scope is accepted but not required.
- Rotation. Every use of a refresh token returns a new refresh token and retires the old one. Store the newest one before you use the new access token.
- No grace window. A retired token is never accepted again, not even a second later.
- Reuse ends the family. Presenting a retired token fails with
invalid_grantand removes every refresh token that descends from the same sign-in, including the newest. The person has to sign in again. Two requests that refresh with the same token at the same time therefore end the session: refresh from one place and serialise it, and do not retry a refresh request that may already have reached the server. - Code replay. Presenting an authorization code a second time fails with
invalid_grantand removes the refresh tokens issued from the first use. Access tokens already issued stay valid until they expire. Used codes are remembered for a day. - Narrowing. A refresh request may ask for fewer scopes than the original grant, never more, and a
resourcemust equal the original one. An ID token is issued again when the scope includesopenid. - Revoking.
POST /revokewith a refresh token removes the whole family (the answer is always 200). Blocking a user ends their refresh tokens too.
Consent
A client created through the management API is first-party by default (firstParty: true): its users never see a consent screen. Set firstParty: false to show one. Clients registered dynamically at /register and clients identified by a client metadata document are never first-party, so their users always see the consent screen the first time.
Consent is remembered per person, client and scope: the screen shows again only when a request asks for a scope the person has not agreed to for that client. Signing out does not forget it. For a client that is not first-party, prompt=none returns consent_required until the person has agreed once.
Where the email address is
The access token carries no personal data: iss, sub, aud, exp, iat, jti, scope and client_id (test users add test and amr). aud is the resource of the authorization request, else the issuer; a test login link takes a resource too, so test tokens can have the same audience as production ones. Use the access token to call your API and read the profile from one of these:
- the ID token, with
scopecontainingopenidandemail:emailandemail_verified, when the person has an email address; - the userinfo endpoint, called with the access token as a bearer token: the access token must carry
openid, andemailfor the address (profileaddsnameandpicture).
A person can have no email address at all (a Steam sign-in has none), so treat email as optional. Use sub to identify a user.
Next: the quick start shows sign-out with a concrete address, and test users describes the limits of automated test logins.