Skip to content
Workforce IdentityMarkdown

Resource indicators

Each token names the one API it is meant for, so an API never accepts a token meant for another.

AvailableAPIRFC 8707

Every token the realm issues names the API it is for, and only that API accepts it. A token stolen from one API can’t be replayed against another. The client names the API by its URL in the resource parameter when it asks for a token; when it names none, the realm uses the client’s default.

Use it whenever a client calls more than one API: give it one token per API. If a client calls a single API, set that API as its default audience and the client need not name it.

  • Who can do it: a realm administrator (a group holding RealmOwner) lists each client’s APIs; RealmViewer can read them. The client names an API on each request.
  • Where: today this is done through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: give each API a name: an https URL, such as https://app.example.com/api.

The client names the API in the token request:

Terminal window
curl https://foobar.cvyuh.com/oauth2/token \
-d grant_type=client_credentials \
-d client_id=orders-sync \
-d scope=orders.read \
-d client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
-d client_assertion=eyJ… \
--data-urlencode resource=https://orders.example.com/api

The token’s audience, its aud claim, is https://orders.example.com/api. resource may be repeated to name several APIs in one request, and the token’s aud then names each of them. Each resource must be an absolute URI with no fragment (no #… part).

The same parameter works in every grant: the browser sign-in, a refresh, and token exchange, where the API may also be named with audience.

List each client’s APIs on the client (https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client; see Call the API), and set the realm’s rules with PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings:

WhereSettingWhat it does
ClientallowedResourcesThe APIs this client may get tokens for: each an https URI with no fragment. Empty by default
ClientdefaultAudienceThe API used when the client names none. Absent by default, so a request naming none is refused
ClientservesResourcesFor an API’s own client: the audiences it may introspect
RealmrequireResourceRefuse any request that names no API (default off)
RealmcimdResourcesThe APIs a metadata-document client may name. Empty by default
Setting or limitDefaultRange
allowedResourcesemptyabsolute https URIs with no fragment
defaultAudiencenone: a request naming no API is refusedone of allowedResources
requireResourceoffon or off
cimdResourcesemptyabsolute URIs
SymptomCauseFix
invalid_target on a request that names no APIThe client has no defaultAudience, or the realm sets requireResourceSet defaultAudience, or have the client send resource
invalid_target naming a known APIIt isn’t on this client’s allowedResources, or differs by a trailing slash or caseAdd the exact URI the client sends
Your API refuses the tokenThe token’s aud is another APICheck which resource the client sent

Each token request’s TOKEN_ISSUED record shows what was asked (asked.resource) beside what was granted (granted.audience), so a refused invalid_target shows the API the client named. See them in Audit → Authentication.

  • A client may name only the APIs on its allowed list. Anything else is refused as invalid_target.
  • Every token has an audience. A client with no default that names none is refused invalid_target.
  • A refresh may name fewer APIs than the sign-in did, never more.
  • With openid, the token is also good at the realm’s own userinfo endpoint.
  • In a token exchange, the API is named with resource, or with audience naming the same registered API. Both together must name the same API, or the request is refused invalid_request.
  • A metadata-document client with no registration of its own may name only the realm’s cimdResources. When that list holds exactly one API, it’s the client’s default audience.
ErrorWhen
invalid_targetA resource isn’t an absolute URI, has a fragment, or isn’t on the client’s allowedResources
invalid_targetThe request names no resource, and the realm sets requireResource
invalid_targetThe request names no resource, and the client has no defaultAudience
invalid_targetA refresh names an API the sign-in didn’t