OIDC Integration
Claxx Auth is a standards-compliant OpenID Connect provider. Downstream Claxx apps sign users in by redirecting them to Claxx Auth, exchanging a one-time authorization code for signed tokens, and validating the ID token. This page walks through the full flow and documents the exact parameters, claims, and error conditions a production client must handle.
Every Claxx app integrates via this path.
Discovery
Claxx Auth publishes a spec-compliant discovery document:
# The issuer is your tenant's hostname. Use the one in your integration guide.
GET https://auth.example.com/.well-known/openid-configuration
{
"issuer": "https://auth.example.com",
"authorization_endpoint": "https://auth.example.com/api/oidc/authorize",
"token_endpoint": "https://auth.example.com/api/oidc/token",
"userinfo_endpoint": "https://auth.example.com/api/oidc/userinfo",
"jwks_uri": "https://auth.example.com/api/oidc/jwks",
"introspection_endpoint": "https://auth.example.com/api/oidc/token/introspect",
"revocation_endpoint": "https://auth.example.com/api/oidc/token/revoke",
"end_session_endpoint": "https://auth.example.com/api/oidc/end-session",
"scopes_supported": ["openid", "profile", "email"],
"response_types_supported": ["code"],
"grant_types_supported": ["authorization_code", "client_credentials"],
"subject_types_supported": ["pairwise"],
"id_token_signing_alg_values_supported": ["ES256"],
"token_endpoint_auth_methods_supported": ["private_key_jwt"],
"code_challenge_methods_supported": ["S256"],
"authorization_response_iss_parameter_supported": true
}
Your OIDC client library should consume the discovery document and reuse its URLs. Do not hardcode endpoints — they are versioned with the service.
Source: server/routes/.well-known/openid-configuration.get.ts.
Register a client
Before integrating, ask a Claxx Auth admin to create an OAuth client for your app (see /admin/clients). You will receive:
- Client ID: a UUID. Used as
client_idand as theaudclaim in ID tokens. - Client authentication:
private_key_jwtfor every application, with a key ID and an ES256 private key that the admin gives you once and that stays on your server. There is no client secret, and there is no browser-only (single-page) client: the sign-in runs on your server. See Client authentication. - Allowed scopes: typically
openid profile email.adminis never available to an application that signs people in: see Application types and the admin scope. - Redirect URIs: Claxx Auth rejects any
redirect_urithat is not exactly one of the registered values. See Redirect addresses. - Post-logout redirect URIs: registered separately from redirect URIs, under the same rules. Every application that signs people in has at least one.
Redirect addresses
Redirect URIs and post-logout redirect URIs follow one rule, when an admin registers them and when your application sends them:
- an absolute
https://address; plainhttp://only onlocalhost,127.0.0.1and[::1], for development; - no user name or password, no fragment (
#...), no query (?...), and no*. Nothing is a pattern: each address is registered in full; - the address you send is accepted only when, once normalized the way a URL parser does it, it equals a registered one. The scheme, host, port and path must be the same. A host in capitals is the same host and
:443on https is the same as no port; a trailing slash, another port, another path or an added query is not.
For the Nuxt module the two addresses are https://<your app>/auth/callback and https://<your app>/.
Application types and the admin scope
| Type | Signs people in | Grants it may use | admin scope |
|---|---|---|---|
confidential | Yes | authorization_code | Never |
service | No | client_credentials only | Allowed |
New applications are confidential or service. An older record of type public still signs people in with authorization_code and its private key, but cannot use client_credentials, sign-in links or the session revoke endpoint; ask an admin for a confidential application instead.
- A service application is a server's key. It has no redirect URIs. The authorization endpoint answers it with
unauthorized_client(as a JSON body on this host, since there is no redirect URI to send it to), and so do the token endpoint forauthorization_code,/api/oidc/sign-in-link,/api/oidc/session/checkand/api/oidc/session/revoke. It may call/api/oidc/tokenwithclient_credentials, and/api/oidc/token/introspectand/api/oidc/token/revokefor its own tokens. adminlets aclient_credentialstoken call the admin API: as an admin of the application's tenant, or as a platform admin when the application belongs to the platform's own tenant (on the platform's own address only). Only a service application may hold it, and only a platform admin signed in to the admin pages can give it. Every admin request made with such a token is recorded (admin.service_token.used).- A request for
adminat/api/oidc/authorizeis refused withinvalid_scope. A token issued to a person never carriesadmin, and only a service application can ask for aclient_credentialstoken (any other is answeredunauthorized_client).
The authorization code flow with PKCE
PKCE is required for every client, on top of the client's key. Claxx Auth rejects any code_challenge_method other than S256, and rejects authorization requests without a nonce.
1. Generate PKCE values and anti-forgery state
import { randomBytes, createHash } from 'node:crypto';
const codeVerifier = randomBytes(64).toString('base64url'); // 43–128 chars
const codeChallenge = createHash('sha256').update(codeVerifier).digest('base64url');
const state = randomBytes(32).toString('base64url');
const nonce = randomBytes(32).toString('base64url');
Persist codeVerifier, state, and nonce in a server-side session keyed to the browser (or a signed, HttpOnly cookie). The values must survive the round-trip to Claxx Auth.
2. Redirect the user to the authorization endpoint
GET https://auth.example.com/api/oidc/authorize
?client_id=7f9b0e7e-...-a11c
&redirect_uri=https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback
&response_type=code
&scope=openid%20profile%20email
&state=<opaque>
&nonce=<opaque>
&code_challenge=<pkce-challenge>
&code_challenge_method=S256
Required parameters:
| Parameter | Value |
|---|---|
client_id | Registered client UUID. |
redirect_uri | Exactly one of the client's registered URIs, after normalizing (rules). |
response_type | code. Any other value returns unsupported_response_type. |
scope | Space-separated. Must include openid, and every scope must be in the client's allowedScopes. |
state | Random opaque value; echoed back on callback. |
nonce | Random opaque value; mirrored into the ID token's nonce claim. |
code_challenge | Base64url-encoded SHA-256 of the code verifier. |
code_challenge_method | S256. |
Optional parameters:
| Parameter | Value |
|---|---|
prompt | login makes the person sign in again even if they have a session. none answers without showing a page, or fails with login_required. consent and select_account have no effect. |
max_age | Seconds. A session authenticated longer ago than this is treated like prompt=login. 0 always asks for a sign-in. |
login_hint | An email address to fill in on the sign-in page. |
The person's browser carries the authorization request, so they can remove prompt or max_age from it. When your application depends on a recent sign-in, check the auth_time claim of the ID token: it is signed. The Nuxt module does this for you.
A request without openid in scope is refused with invalid_scope: this is an OpenID Connect provider, and without openid there is no ID token to say who signed in.
Every answer sent to your redirect_uri carries iss, the issuer from discovery (RFC 9207), and discovery says so with authorization_response_iss_parameter_supported: true:
- success:
?code=<code>&state=<echoed>&iss=<issuer>; - error:
?error=<code>&error_description=<text>&state=<echoed>&iss=<issuer>.
On the callback, check state, then refuse the response unless iss is present and is exactly the issuer you configured. That is what stops an answer from another provider (or another tenant's address) being taken for this one's. error_description is one fixed sentence per error code; do not parse it.
Once client_id and redirect_uri are found valid, every other fault is sent to your redirect_uri that way. A request with an unknown client or an unregistered redirect URI is answered on the Claxx Auth host instead, because there is then nowhere safe to send the browser.
Source: server/api/oidc/authorize.get.ts.
3. Claxx Auth handles the user
- If the user has an active Claxx Auth session, Claxx Auth issues an authorization code and redirects back immediately (silent re-auth).
- Otherwise, Claxx Auth renders the hosted login page, completes sign-in (local password or federated), and then issues the code.
- If the user requires a forced password reset, Claxx Auth sends them through
/reset-passwordfirst, returning to the authorize flow on completion. - If the user denies consent or cancels, Claxx Auth redirects to
redirect_uriwith?error=access_denied&state=<echoed>.
4. Exchange the code at the token endpoint
POST https://auth.example.com/api/oidc/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=<code>
&redirect_uri=https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback
&client_id=7f9b0e7e-...-a11c
&code_verifier=<pkce-verifier>
&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
&client_assertion=<signed-jwt>
Every application authenticates with private_key_jwt, the only method in token_endpoint_auth_methods_supported. There is no PKCE-only exchange and no client secret, so the exchange is made from your server.
The authorization code lives 60 seconds and works once. Redeem it straight after the redirect.
Client authentication
The client_assertion (RFC 7523) is a JWT signed with the application's registered key. The same assertion rules apply at every endpoint that takes one (token, introspection, revocation, sign-in link, session check and revoke).
| Part | Requirement |
|---|---|
Header alg | ES256. Anything else, HS256 and none included, is refused. |
Header kid | The application's Client Assertion Key ID. |
iss and sub | The client ID. |
aud | The token endpoint URL from discovery, or the URL of the endpoint being called. Another endpoint's URL, or another issuer's, is refused. |
jti | Required. A new random value for every assertion. |
iat | Required. Not in the future, and not more than five minutes ago. |
exp | Required. In the future, and not more than five minutes ahead. |
The iat and exp limits allow 60 seconds of clock difference; an exp that has passed is refused with none. Each assertion is accepted once: its jti is recorded for the application in the database, so presenting it again, on any instance of the service, is refused with invalid_client until it expires. Sign a new assertion for every request.
Successful response (tokens trimmed for readability):
{
"access_token": "eyJhbGciOiJFUzI1NiIsImtpZCI6ImJsdWF1dGgtMTcx...",
"id_token": "eyJhbGciOiJFUzI1NiIsImtpZCI6ImJsdWF1dGgtMTcx...",
"token_type": "Bearer",
"expires_in": 3600
}
Both tokens are ES256-signed JWTs (EC P-256, alg: "ES256"). Their typ header tells them apart: at+jwt for the access token (RFC 9068), JWT for the ID token. They last as long as the person's sign-in at Claxx Auth has left, one hour at most: read expires_in, do not assume 3600. A code whose sign-in has ended is refused with invalid_grant. Response headers include Cache-Control: no-store and Pragma: no-cache per RFC 6749 §5.1.
Source: server/api/oidc/token.post.ts, server/utils/oidc/tokens.ts.
5. Validate the ID token
Validate, in order:
- Signature. Fetch the JWKS from
/api/oidc/jwks, select the key matching the JWT'skid, and verify with ES256. typisJWT. An access token (at+jwt) is signed by the same key for the same audience: never accept one as an ID token.issequals the issuer returned by discovery (e.g.https://auth.example.com).audequals your client ID.expis in the future;iatis not in the future (allow 2 minutes of skew).nonceequals the value you sent in step 2.at_hashmatches the left-most 128 bits of SHA-256 of the access token, base64url-encoded.
Any mature OIDC client library performs these checks correctly — use one.
Signing-key rotation
An admin rotates the signing key from the Signing Keys page. The new key signs every token from that moment. The previous key stays in the JWKS, and is still accepted by Claxx Auth itself, until every token it signed has expired: an hour (the longest a token lives), plus five minutes for another instance of the service that still holds the old key, plus a minute of clock difference. Then it leaves the JWKS. So a token signed a moment before a rotation keeps verifying until it expires.
Cache the JWKS, but fetch it again when a token names a kid you do not have. The response says Cache-Control: public, max-age=300: keep a copy for five minutes at most. Consumers that hardcode JWKS responses will break.
6. Call userinfo (optional)
GET https://auth.example.com/api/oidc/userinfo
Authorization: Bearer <access_token>
{
"sub": "6f2a8e7e-...-pairwise",
"name": "Jane Doe",
"given_name": "Jane",
"family_name": "Doe",
"picture": "https://cdn.example.com/u/jane.png",
"email": "jane@example.com",
"email_verified": true,
"emails": ["jane@example.com", "jane.doe@example.com"],
"auth_method": "password",
"linked_providers": ["google"],
"current_provider": "credential",
"mfa_satisfied": true,
"auth_assurance_level": "aal2",
"assurance_source": "local_2fa"
}
A token that is not good is answered 401 with WWW-Authenticate: Bearer error="invalid_token" and {"error": "invalid_token", "error_description": "..."}: unknown, expired, an ID token instead of an access token, or one that has stopped working.
Returned claims are scoped — you only get profile claims if the profile scope was granted, and only email claims if email was granted. sub is pairwise — the same user has a different sub for each client, derived deterministically. emails lists all verified aliases so downstream apps can match on any of them.
The current_provider, mfa_satisfied, auth_assurance_level, and assurance_source claims describe the current sign-in event, not the user's long-term account shape. Downstream apps can use them for admission control such as provider-constrained access rules or current-session MFA requirements.
They come from what the session recorded when it was created, never from the account's current settings. A person who signs in with a password and then turns two-factor on keeps an aal1 session until they sign in again with their code. What each way of signing in records:
| Sign-in | current_provider | acr | amr | mfa_satisfied | assurance_source |
|---|---|---|---|---|---|
| Password | credential | aal1 | ['pwd'] | false | password |
| Password, then authenticator code or backup code | credential | aal2 | ['pwd', 'mfa'] | true | local_2fa |
| Passkey (the device checked a PIN or biometric) | passkey | aal2 | ['hwk', 'mfa'] | true | passkey |
| Emailed sign-in link | email_link | aal1 | ['otp'] | false | email_link |
| Upstream identity provider | the provider slug | none | none | null | upstream |
A passkey sign-in where the device did not verify the person is refused, so there is no passkey session below aal2.
The authorization endpoint also applies your application's own sign-in rules to the session before it issues a code: a session your application would not have let in is sent back to sign in again (see clients → sign-in rules).
Source: server/utils/oidc/userinfo.ts.
ID token claims
| Claim | Notes |
|---|---|
iss | Issuer, matches discovery. |
sub | Pairwise per (user, client). Stable across sessions. |
aud | Your client ID. |
exp, iat | Expiry and issue time (Unix seconds). At most 1 hour, and never past the end of the sign-in. |
nonce | Echoed from authorize request. |
at_hash | Left half of SHA-256 of the access token. |
auth_time | When the person authenticated (Unix seconds). |
sid | The sign-in, sealed for your application: opaque, different at every application. Send it to POST /api/oidc/session/check. Not a credential. |
session_expires_at | When that sign-in ends at Claxx Auth (Unix seconds). Keep your own session no longer than this. |
acr | Assurance level the session proved: aal1 or aal2. |
amr | ['pwd'], ['pwd', 'mfa'], ['hwk', 'mfa'] for a passkey, or ['otp'] after an emailed sign-in link; absent when federated. |
auth_method | password, <provider-slug>, or service. |
linked_providers | Array of provider slugs the user has linked. |
current_provider | Provider that authenticated the current session. |
mfa_satisfied | true, false, or null for the current session. |
auth_assurance_level | Assurance summary such as aal1, aal2, or null. |
assurance_source | How Claxx Auth derived assurance for the session. |
email, email_verified, emails | Present when email scope granted. |
name, given_name, family_name, picture | Present when profile scope granted. |
When a token stops working
An access token is good at userinfo, at introspection and at /api/provider-tokens only while what it stands for still stands. It stops working at once, not when it expires an hour later, when:
- the sign-in it came from ends: the person signs out here or through the end-session endpoint, a password change or a completed reset ends their other sessions, a passkey removal or an admin ends their sessions, the account is marked to choose a new password, or the sign-in's own time runs out (the tenant's sign-in lifetime, twelve hours at most). Signing in again gives new tokens; the old ones stay dead;
- the person's account is deleted;
- the application is switched off or deleted;
- the person is signed out of the application after the sign-in the token came from (
POST /api/oidc/session/revoke, or Sign out of this application in the admin pages). A sign-in made after the revocation is not touched.
A client_credentials token stops working when its application is switched off, deleted, or is no longer of type service.
Claxx Auth does not look at an ID token again once it is issued. To find out that the sign-in behind your session has ended, or that the person was signed out of your application, ask POST /api/oidc/session/check (see Signing a person out).
Keeping your own session
Your application's session lives only while the sign-in it came from does. The Nuxt module (@claylevering/auth-nuxt) does all of this. An application built without it must do it itself:
- Keep
sub,auth_timeandsidfrom the ID token with your session. Refuse an ID token withoutsid: a session made from it cannot be checked. - End your session no later than
session_expires_at, whatever lifetime you chose for it. Count from when you make it; do not extend it past that moment. - Ask
POST /api/oidc/session/checkfor each active session about once a minute (sub,auth_time,sid, with your client authentication). End the session at once when the answer is{"active": false}. - Treat anything other than
200 {"active": true}as no answer. Keep the session for a limited time after its lasttrue(the module allows fifteen minutes), then end it. Never keep a session running on no answers. - A
401fromuserinfoor/api/provider-tokensfor your session's access token means the sign-in has ended: end the session then too. - Check where the session is read, not only in a middleware that some paths skip. A middleware that leaves build assets or its own routes alone, deciding on a parsed URL, can be walked past with dot segments (
/api/x/%2e%2e/%2e%2e/_nuxt/): a parsed URL resolves them, the router does not. Decide on the path as sent, refuse one with a dot segment, and do the due check in the function every route calls to get the session. A check withoutsidis400 sid_required.
Signing in again is quiet while the person is still signed in here: send the browser through the authorization endpoint, and a live sign-in comes straight back with a code.
Refreshing tokens
Claxx Auth does not issue OAuth refresh tokens to downstream apps today. When an access token expires, your client should re-enter the authorize flow. If the user's Claxx Auth session is still active, Claxx Auth issues a new code without user interaction (prompt=none answers without showing a page, or fails with login_required).
Plan for this on your server: when your own session or the access token runs out, send the browser through the authorization endpoint again (a full navigation), exchange the new code on your server, and resume.
Logout
RP-initiated logout follows OIDC RP-Initiated Logout 1.0:
GET https://auth.example.com/api/oidc/end-session
?id_token_hint=<id_token>
&post_logout_redirect_uri=https%3A%2F%2Fapp.example.com%2Fsigned-out
&state=<opaque>
Claxx Auth clears the Better Auth session cookie, deletes the session row from D1, and redirects to post_logout_redirect_uri when it is exactly one of the registered post-logout redirect URIs of an active client of this tenant (rules). Any other address is not followed: the person is signed out all the same and lands on Claxx Auth's own page. See Session Contract for full logout semantics.
Source: server/api/oidc/end-session.get.ts.
Revocation and introspection
Claxx Auth implements RFC 7009 (Token Revocation) and RFC 7662 (Token Introspection). Both require client authentication, with aud set to the endpoint's URL or the token endpoint's. A client that cannot be authenticated gets 401 {"error": "invalid_client"}.
POST https://auth.example.com/api/oidc/token/revoke
Content-Type: application/x-www-form-urlencoded
token=<access_token>&token_type_hint=access_token
POST https://auth.example.com/api/oidc/token/introspect
Content-Type: application/x-www-form-urlencoded
token=<access_token>
{
"active": true,
"sub": "6f2a8e7e-...-pairwise",
"client_id": "7f9b0e7e-...-a11c",
"scope": "openid profile email",
"token_type": "Bearer",
"exp": 1744823025,
"iat": 1744819425
}
The answer is {"active": false} for a token that is unknown, expired, issued to another client, not an access token (an ID token, say), or one that has stopped working.
Edge cases
- State mismatch on callback. Reject the response and restart the flow. Never trust an unvalidated
state. - Expired code. Codes are valid for 60 seconds. Attempting to exchange an expired code returns
invalid_grant. - Reused code. Codes are single-use. The exchange takes the code out of the store in one step, so of two requests with the same code exactly one gets tokens; the other gets
invalid_grant. Only a hash of each code is stored. - A failed exchange uses the code up. A wrong
code_verifier,redirect_urior client still consumes the code. Start a new sign-in; do not retry the exchange. - PKCE verifier mismatch. Returns
invalid_grant. Ensure you're sending the exact verifier you generated — not the challenge. - Replayed client assertion. An assertion is accepted once. Reusing one returns
invalid_client. - Scope escalation. Requesting a scope outside
allowedScopes, oradminat all, or leaving outopenid, aborts the flow at/authorizewithinvalid_scope. - Changing
redirect_urimid-flow. The value in step 4 must be the same text as in step 2, character for character. - A redirect URI that is almost right. A trailing slash, another port, another path or an added query is a different address and is refused at
/authorizewithInvalid redirect_uri, shown on Claxx Auth's host.
Example client (Node + openid-client)
import { Issuer, generators } from 'openid-client';
const issuer = await Issuer.discover('https://auth.example.com');
const client = new issuer.Client(
{
client_id: '7f9b0e7e-...-a11c',
redirect_uris: ['https://app.example.com/auth/callback'],
response_types: ['code'],
token_endpoint_auth_method: 'private_key_jwt',
id_token_signed_response_alg: 'ES256'
},
{
keys: [
/* your JWK */
]
}
);
// Redirect
const code_verifier = generators.codeVerifier();
const code_challenge = generators.codeChallenge(code_verifier);
const state = generators.state();
const nonce = generators.nonce();
const authUrl = client.authorizationUrl({
scope: 'openid profile email',
code_challenge,
code_challenge_method: 'S256',
state,
nonce
});
// Callback
const params = client.callbackParams(req);
const tokenSet = await client.callback('https://app.example.com/auth/callback', params, { code_verifier, state, nonce });
const claims = tokenSet.claims();
Errors
Claxx Auth returns spec-compliant OAuth 2.0 error responses on the authorize endpoint (query-string redirect, with iss), on the token, introspection and revocation endpoints (JSON body), and on userinfo (401 with WWW-Authenticate: Bearer error="invalid_token"). The error_description is a fixed sentence for each code and says nothing about the particular request; Claxx Auth records the reason in its audit log.
| Error | Meaning |
|---|---|
invalid_request | Missing or malformed parameter. |
unauthorized_client | Client exists but isn't allowed for this grant or scope. |
access_denied | User cancelled, denied consent, or was blocked by policy. |
invalid_grant | Code expired, already used, or PKCE verifier mismatched. |
invalid_client | Client authentication failed (HTTP 401): a missing, malformed, expired, replayed or wrongly signed assertion, or an unknown or switched-off client. |
unsupported_grant_type | grant_type was not one the token endpoint supports. |
login_required | prompt=none, and the person must sign in first. |
interaction_required | prompt=none, and the person must set a new password. |
invalid_scope | openid is missing, a requested scope isn't in allowedScopes, or it is admin. |
unsupported_response_type | response_type was not code. |
invalid_token | userinfo only: the access token is not good (HTTP 401). |
server_error | Internal — report with request ID. |
For full server-side error codes and JSON response shapes see API errors and the API reference.
Picking a library
Any conformant OIDC client library that runs on a server and supports private_key_jwt works. A library that runs only in the browser cannot keep the private key, and Claxx Auth has no client that signs in without one. For a Nuxt application, use the @claylevering/auth-nuxt module.
- Node / TypeScript (server):
openid-client. - Go:
go-oidc. - Python:
authlib. - Rust:
openidconnect.
Always configure via discovery URL. Always verify ID token signatures against the JWKS. Never skip nonce validation.