Resource servers
Register your API in a realm, request tokens addressed to it with the resource parameter (RFC 8707), and validate them in the API.
A resource server is an API — a REST service, an MCP server — that accepts a realm’s access tokens. Registering it gives it an identifier that tokens carry as their audience (aud), a set of scopes of its own and the list of clients allowed to request tokens for it.
The audience matters because every client of a realm publishes its signing keys in the same key set: a valid signature only proves that the token came from the realm. The audience is what says it was meant for your API, so a token issued for another application of the same realm is refused.
Register an API
Open Resource Servers, choose New resource server and pick the realm whose tokens the API will accept.
| Field | Rules |
|---|---|
| Identifier | The API’s canonical http or https URL, such as https://api.acme.com, without a fragment and up to 512 characters. Scheme and host are lowercased, and a default port or a trailing slash removed. Unique in the realm and fixed once created, because every token issued for it carries it. |
| Name and description | Up to 128 and 512 characters. |
| Scopes | At least one, such as documents:read. Up to 128 characters each, without spaces, quotes or backslashes, case-sensitive and not repeated. |
| Allowed clients | The clients of the same realm that may request tokens for it. Being in the realm is not enough. |
| Accept CIMD clients | Lets MCP clients that registered themselves with a Client ID Metadata Document request tokens for it. |
| Accept dynamically registered clients | Lets clients created through the realm’s dynamic client registration endpoint request tokens for it. Off by default; see MCP. |
| Introspection client | A confidential client of the realm that the API uses to ask whether a token is still active. |
Through the admin API, resource servers live under /api/v1/admin/realms/{realm}/resource-servers: GET, POST, PUT /{id}, DELETE /{id}, and GET /{id}/activity for the numbers below. Reading takes client:read, writing client:write, client:update or client:delete, and the activity audit:read.
On Node.js, admin.resourceServer of @hyper.authio/admin covers these routes — getAll, getById, create, update, delete and getActivity — with admin the client of The Admin API from the libraries. On .NET, IAuthioAdminClient has no method for them: call them with an `HttpClient` that carries `AddAuthioAccountCredential()`.
const server = await admin.resourceServer.create({
realm: 'acme',
body: {
identifier: 'https://api.acme.com',
name: 'Acme API',
scopes: [
{ name: 'documents:read', description: 'Read documents' },
{ name: 'documents:write', description: 'Change documents' },
],
clientIds: ['acme-web', 'acme-worker'],
allowMetadataDocumentClients: false,
allowDynamicallyRegisteredClients: false,
introspectionClientId: 'acme-api',
},
})| Error code | Why |
|---|---|
ResourceServerAlreadyExists | The realm already has a server with this identifier. |
ResourceServerIdentifierInvalid | The identifier is not an absolute http or https URL without a fragment. |
ResourceServerScopesRequired | No scope was given. |
ResourceServerScopeInvalid, ResourceServerScopeDuplicated | A scope name is empty, too long or holds a forbidden character, or appears twice. |
ResourceServerClientOutsideRealm | An allowed client does not exist in the server’s realm. |
ResourceServerIntrospectionClientNotConfidential | The introspection client is public and has no secret to authenticate with. |
McpIntegrationNotIncluded | The server admits self-registered clients and the plan does not include the MCP integration. |
ResourceServerLimitExceeded | The plan’s cap on active resource servers is reached. |
IntegrationLicenseSuspended | The subscription is not in force. |
- Deactivating keeps the identifier, scopes and clients, and stops new tokens for it at once.
- Deleting removes its scopes and client list and leaves the clients themselves untouched; tokens already issued stay valid until they expire.
- On edit, the scopes and clients you save replace the previous ones.
Request tokens for an API
Name the API with the resource parameter of RFC 8707 and ask for its scopes in scope. An authorization request takes at most one resource.
The Authio libraries send it for you. A worker names it in clientCredentialsFetch or tokens.clientCredentials of @hyper.authio/client, or in AddAuthioClientCredentials of Authio.Client. A sign-in names it in the authorization.params of @hyper.authio/provider-nextauth, in createAuthorizationUrl of @hyper.authio/client and the options of @hyper.authio/bff, and as Resource in the AuthioAuthorizationRequest of Authio.Client and in the Authio:Bff section of Authio.AspNetCore.Bff.
import { createAuthioClient } from '@hyper.authio/client'
const authio = createAuthioClient({
issuer: 'https://authio.api.hyperio.tech/realms/acme',
clientId: 'acme-worker',
clientSecret: process.env.AUTHIO_CLIENT_SECRET,
})
const documentsFetch = authio.clientCredentialsFetch({
scopes: 'documents:read',
resource: 'https://api.acme.com',
})
const response = await documentsFetch('https://api.acme.com/documents')- When the code is exchanged,
resourcecan be left out; if sent, it must match the authorization request. - Refreshes keep the resource of the original authorization, so renewed tokens stay addressed to the same API.
- The resource server and the client’s access to it are checked again on every issuance, refreshes included: a deactivated server, or a client removed from its list, stops receiving tokens at once.
| Error | Why |
|---|---|
invalid_target | More than one resource, or one that names no active resource server this client may request tokens for. |
invalid_scope | A requested scope is neither enabled on the client nor one of the server’s scopes. |
access_denied | The server admits self-registered clients and the plan does not include the MCP integration. |
What the token carries
The access token’s aud is the identifier, and its scope adds the server scopes the request asked for to the ones the client was granted. Without resource, aud is the audience configured on the client.
{
"iss": "https://authio.api.hyperio.tech/realms/acme",
"sub": "6f1c2e7a-4b8d-4f0e-9a51-3c2d7e8b9f10",
"aud": "https://api.acme.com",
"azp": "acme-web",
"typ": "Bearer",
"scope": "openid documents:read",
"iat": 1791370800,
"nbf": 1791370800,
"exp": 1791372600
}A client whose Access Token Format is Lightweight hands your API a smaller JWT, validated exactly the same way. It keeps iss, sub, aud, exp, nbf, iat, jti, client_id, azp, scope, sid, auth_time, acr, amr, idp, the organization (org_id, org_alias) and delegation (act, delegation_id, session_client). The role claims, subscription, account_id, the profile, e-mail and phone, the person’s own claims and those of claim mappers are left out, and introspection answers with all of them.
Libraries that read roles from the token
Validate access tokens in your API
Access tokens are signed JWTs, so your API validates them on its own with the realm’s public keys, without calling Authio on each request. On every request, check:
| Check | Expected |
|---|---|
| Signature | A key of the realm’s JWKS, https://authio.api.hyperio.tech/realms/acme/protocol/openid-connect/certs, picked by the kid header |
iss | https://authio.api.hyperio.tech/realms/acme |
aud | Your API’s identifier, https://api.acme.com |
exp and nbf | The current time falls inside the window |
Header typ | at+jwt (RFC 9068). ID and refresh tokens carry JWT or JWE, so this check alone refuses them. |
typ claim | Bearer. ID tokens carry ID and refresh tokens Refresh. |
scope | Contains the scope the endpoint requires |
| Role claims | Hold the permission the endpoint requires — see Roles and permissions |
With @hyper.authio/express, authioBearer makes every check of the table: it reads the issuer and the keys from the realm’s discovery document, accepts only the audiences you name, and refuses a header typ other than at+jwt and a typ claim other than Bearer. With Authio.AspNetCore, AddAuthioJwtBearer configures the JWT bearer handler to do the same. requireScope and RequireAuthioScope check the scope, and both read the role claims for the permission guards.
import express from 'express'
import { authioBearer, requireScope } from '@hyper.authio/express'
const app = express()
app.use(
'/api',
authioBearer({
issuer: 'https://authio.api.hyperio.tech/realms/acme',
audiences: 'https://api.acme.com',
}),
)
app.get('/api/documents', requireScope('documents:read'), (req, res) => {
res.json({ subject: req.authio!.user.subject })
})
app.listen(3001)A token addressed to another API is refused with an error_description that names the audience the API accepts. On another Node.js framework (Fastify, Hono, Nest, plain http), createAuthioVerifier of @hyper.authio/server makes the same checks. See Node.js and .NET.
Clients that sign access tokens with HS
introspection: 'introspectionOnly' in Node.js, IntrospectionOnly in .NET. The client’s response flags it with accessTokenRequiresIntrospection when a resource server accepts it. See Token signing.Check revocation with introspection
A token validated locally stays valid until it expires, even after its session ended or its user was suspended. When the API must know at once, ask the realm with the server’s introspection client (RFC 7662).
With introspection: 'activeCheck' in @hyper.authio/express and Introspection set to ActiveCheck in Authio.AspNetCore, the API validates the token locally and then asks Authio whether it is still active, keeping an active answer for 30 seconds. Both authenticate as the introspection client, acme-api here; in ASP.NET Core, AddAuthioClient registers it from the same section, and its secret comes from dotnet user-secrets or the Authio__ClientSecret environment variable. To ask yourself, introspect of @hyper.authio/client and IntrospectAsync of IAuthioIntrospectionClient return the answer as Authio sent it.
app.use(
'/api',
authioBearer({
issuer: 'https://authio.api.hyperio.tech/realms/acme',
audiences: 'https://api.acme.com',
introspection: 'activeCheck',
client: { clientId: 'acme-api', clientSecret: process.env.AUTHIO_CLIENT_SECRET },
}),
)- The answer is always
200. A token that is expired, revoked, from an ended session or never valid gets only{"active": false}, with no reason. - The introspection client sees the tokens addressed to its resource servers, even when another client requested them.
- An active answer also returns the role claims,
acr,amr, the organization and, for delegated tokens,actanddelegation_id. - For a lightweight token, the answer carries the claims of the full token, which Authio keeps until the access token expires. Without it, the answer carries only what the lightweight token holds, so a permission check denies rather than allows.
Activity
The Activity section of the resource server’s page counts, over 7, 30 or 90 days, the tokens issued and refused for it, the connected-account exchanges it made and the introspections it ran, with the most active clients and users and the most common reasons for refusal.