Skip to content

Tokens

An ID token is a signed JWT that tells your application who signed in. It contains sub (the user’s ID), and the email address, name and other profile details your application asked for through its scopes. It also includes auth_time, amr (how they signed in), sid (their session) and the nonce your application sent.

ID tokens are signed with RS256 by default, which every OpenID Connect library supports. If your library supports it, an application can choose ES256 instead, which gives smaller tokens. Your library checks the signature using the keys published at <issuer>/oauth2/jwks.

An access token is what your application sends when it calls an API. It’s a JWT signed with ES256 (typ: at+jwt, as described in RFC 9068), and it contains iss, sub and aud, along with scope, client_id and roles, and exp, iat and jti.

Its audience (aud) depends on what the application asked for. If it named one of your API resources, the audience is that API’s identifier, along with your project’s userinfo endpoint (<issuer>/oauth2/userinfo) when the openid scope was requested. If it didn’t name an API, the token is for your project itself, and its audience is your issuer. Access tokens last 15 minutes by default. You can change this under Sessions and tokens, or for an individual application.

On the Paid plan, an application can receive opaque access tokens instead, which it can’t read. Your backend checks them using the introspection endpoint (RFC 7662). Third-party applications always receive opaque tokens unless they’ve asked for one of your APIs.

If an application asks for the offline_access scope, it also gets a refresh token so that people stay signed in.

By default, each refresh token can be used only once, and a new one is issued each time. If someone presents a refresh token that has already been used, authN assumes it was copied and ends the whole grant. A short grace period allows for two browser tabs refreshing at the same moment.

Refresh tokens stop working after a period without use, which is 30 days by default. You can also set a maximum lifetime, after which people have to sign in again however active they’ve been.

When an application sends a DPoP proof, its tokens are bound to the application’s key and are useless without it. See Native apps and biometrics.

You can end a refresh token and its grant with the revocation endpoint (/oauth2/revoke, RFC 7009). Signing out at /oauth2/end_session ends the person’s session, along with the refresh grants issued during it. Disabling or deleting a user ends all of their sessions and grants, and when someone removes an application’s access from their account page, that application’s grant ends too.

An access token belongs to the refresh grant it was issued with, or to the session it came from if there’s no grant. Once that grant or session has ended, authN’s introspection and userinfo endpoints treat the token as no longer valid. An API that checks access tokens itself, from their signature, can’t know this, and will accept the token until it expires. Keep access tokens short-lived (15 minutes by default), or use introspection, if your API needs to notice straight away.

  1. Fetch the keys from <issuer>/oauth2/jwks and cache them.
  2. Check the signature (ES256), and that iss is your issuer, aud is your API’s identifier, exp hasn’t passed and typ is at+jwt.
  3. Read sub, scope and roles to decide what the request is allowed to do.
  4. If the token contains cnf.jkt, it’s bound to a key, so require a DPoP proof as described in Native apps.