The sign-in flow
Tessera uses the OAuth authorization code flow with PKCE (S256); this page shows each request and response, so you can check what your OIDC library sends.
On this page
Tessera uses the OAuth authorization code flow with PKCE (S256); this page shows each request and response, so you can check what your OIDC library sends.
Examples use the shared issuer https://login.kurthlabs.com/realms/acme, the client acme-web and the redirect URI https://app.example.com/auth/callback. On a realm with its own login domain the endpoints sit at that domain without the /realms/<realm> part; always read the real URLs from discovery.
1. Discover the endpoints
GET /realms/acme/.well-known/openid-configuration HTTP/1.1
Host: login.kurthlabs.com{
"issuer": "https://login.kurthlabs.com/realms/acme",
"authorization_endpoint": "https://login.kurthlabs.com/realms/acme/authorize",
"token_endpoint": "https://login.kurthlabs.com/realms/acme/token",
"jwks_uri": "https://login.kurthlabs.com/realms/acme/jwks",
"userinfo_endpoint": "https://login.kurthlabs.com/realms/acme/userinfo",
"end_session_endpoint": "https://login.kurthlabs.com/realms/acme/logout",
"response_types_supported": ["code"],
"code_challenge_methods_supported": ["S256"],
"authorization_response_iss_parameter_supported": true,
"scopes_supported": ["openid", "profile", "email", "address", "phone", "offline_access"],
"id_token_signing_alg_values_supported": ["EdDSA", "RS256"]
}The real document has more fields; see Endpoints. It is cached for one hour (Cache-Control: public, max-age=3600). Check that issuer equals the issuer you configured.
2. Send the person to authorize
Create three random values and keep them in the visitor's server-side session or a short-lived HttpOnly cookie:
code_verifier: 43 to 128 random characters fromA-Z a-z 0-9 - . _ ~. The challenge isBASE64URL(SHA256(code_verifier)), which is 43 characters.state: ties the response to this visit. Tessera refuses a request without it.nonce: ties the ID token to this visit. Optional on the wire, but send it.
GET /realms/acme/authorize
?response_type=code
&client_id=acme-web
&redirect_uri=https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback
&scope=openid%20profile%20email%20offline_access
&state=Zy3Q8dK1
&nonce=n-0S6_WzA2Mj
&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
&code_challenge_method=S256 HTTP/1.1
Host: login.kurthlabs.comAuthorize is a browser redirect, so it takes GET with the parameters in the query string and answers no other method. Every endpoint your server calls directly (/token, /revoke, /introspect) takes its parameters in a form-encoded POST body instead and ignores the query string.
| Parameter | Notes |
|---|---|
response_type |
Must be code. |
redirect_uri |
Must match a registered URI exactly (scheme, host, port, path, trailing slash). One exception for native apps: a registered http://127.0.0.1 or http://[::1] URI also matches the same URI with any port, because the app picks a free port at run time. localhost is not port-flexible. |
scope |
openid for an ID token; profile, email add claims; offline_access asks for a refresh token. |
code_challenge, code_challenge_method |
S256 only. plain is refused. |
resource |
Only for an app that has an API or is an MCP client (RFC 8707). It becomes the access token's aud and must be one of the client's allowed resources. Repeat it for several. A plain OIDC app leaves it out. |
prompt |
none, login, consent or select_account. none cannot be combined with another value and returns login_required instead of showing a page. |
max_age, acr_values, login_hint |
Optional. acr_values must be a value the realm supports. |
response_mode |
query (default), fragment or form_post. |
What resource does depends on the client:
- A plain OIDC app (a client with no allowed resources, which is what
tessera initand the console create) sends noresource. Its access token'saudis its ownclient_id, which is also what userinfo accepts. - An app with an API lists the API's identifier in its allowed resources. A request with no
resourcethen uses the first allowed one. - An MCP client must always name its resource. See Protect an MCP server.
The person signs in on Tessera's hosted pages. What they see depends on the realm: with email-first sign-in they enter an email address, and Tessera either sends them on to their company's identity provider (when the address's domain is routed to one) or emails a six-digit code and a sign-in link that only work in the browser that asked; a passkey or a password can be offered too. See Sign-in methods. None of this changes the requests on this page. Tessera then redirects:
HTTP/1.1 303 See Other
Location: https://app.example.com/auth/callback?code=Sm3f...&state=Zy3Q8dK1&iss=https%3A%2F%2Flogin.kurthlabs.com%2Frealms%2FacmeCheck that state matches the one you stored. The code is single use and expires after 60 seconds. The iss parameter (RFC 9207) names the issuer that answered; if your app talks to more than one issuer, compare it with the issuer you started the flow at, and discard the response when it differs. Most OIDC libraries do this for you. It also appears on error redirects.
Most mistakes in the request (an unknown client, a redirect_uri that is not registered, a missing state, a missing or malformed PKCE challenge, a scope or resource the client may not use) show a hosted error page with an error_code and never redirect, because the redirect target is not yet trusted. Tessera redirects with error, error_code, error_uri, state and iss for the outcomes your app is expected to handle: login_required or interaction_required for prompt=none, access_denied when the person declines or may not use the app, consent_required, and invalid_request for a bad prompt or response_mode.
3. Exchange the code
Confidential client, secret in HTTP Basic:
POST /realms/acme/token HTTP/1.1
Host: login.kurthlabs.com
Authorization: Basic YWNtZS13ZWI6c2VjcmV0
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=Sm3f...
&redirect_uri=https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback
&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXkA public client sends client_id=acme-web in the body and no secret. Confidential clients may also use client_secret_post or private_key_jwt. See Client types.
Send every parameter in the body, never in the query string. The code_verifier is the one you made in step 2: 43 to 128 characters from A-Z a-z 0-9 - . _ ~.
{
"access_token": "eyJ...",
"token_type": "Bearer",
"expires_in": 900,
"refresh_token": "Xk9...",
"scope": "openid profile email offline_access",
"id_token": "eyJ..."
}expires_inis the realm's access token lifetime. The default is 900 seconds.refresh_tokenappears only when the scope includesoffline_accessand the client may use therefresh_tokengrant.id_tokenappears when the scope includesopenid.- A reused or expired code, a code issued to another client, a different
redirect_urior a wrongcode_verifierall answer400witherror: invalid_grant. Presenting a code a second time also revokes the refresh tokens that the first exchange produced, so a stolen code cannot be quietly replayed. - For a plain OIDC app the access token's
audis theclient_id. Roles of the apps that list the client ride on it; see Token claims.
4. Validate the ID token
Your library does this. If you do it yourself, check all of these before you trust the token:
- The signature, using the key in
jwks_uriwhosekidmatches the token header. The algorithm isEdDSAby default, orRS256if the client is set to that. issequals your issuer.audequals your client ID.expis in the future (allow a little clock skew).nonceequals the one you sent.
The header typ is JWT. Access tokens use at+jwt, so an ID token is never accepted as an access token. Claims are listed in Token claims.
5. Read the user's details
Use the ID token claims, or call userinfo with the access token. It answers GET and POST, and a missing or invalid token gets 401 with a WWW-Authenticate: Bearer challenge:
GET /realms/acme/userinfo HTTP/1.1
Host: login.kurthlabs.com
Authorization: Bearer eyJ...{
"sub": "0194f3c2-6f1a-7c1e-9d2b-3a4b5c6d7e8f",
"email": "ada@example.com",
"email_verified": true,
"preferred_username": "ada",
"groups": []
}email and email_verified need the email scope; preferred_username needs profile. sub is a stable user ID: key your accounts on it, never on the email address.
6. Refresh
POST /realms/acme/token HTTP/1.1
Host: login.kurthlabs.com
Authorization: Basic YWNtZS13ZWI6c2VjcmV0
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&refresh_token=Xk9...The answer has the same shape as step 3 with a new access_token, id_token and refresh_token. Refresh tokens rotate: store the new one and drop the old one. Presenting an old one again is treated as theft and revokes the chain. The default lifetime is 30 days.
invalid_grant means the grant is over: the token expired, was revoked, or the person's Tessera session ended. Clear your session and send the person to sign in again.
Errors
Token and revoke errors are JSON with the standard error and error_description plus Tessera's error_code and error_uri. See Error codes.
{
"error": "invalid_grant",
"error_description": "authorization code is invalid or already used. Exchange each code once, within 60 seconds, from the client it was issued to, with the identical redirect_uri. A reused code also revokes what it produced; start a new authorization.",
"error_code": "authorization_code_invalid",
"error_uri": "https://docs.kurthlabs.com/tessera/errors/authorization_code_invalid"
}