OAuth audience restriction: allow an access token only at its intended API
Learn how audience limits where an access token works, how that differs from scope, and how clients and APIs verify the restriction.
OAuth audience restriction: allow an access token only at its intended API
Audience restriction limits an access token to one intended API or a small set of resources. The authorization server can indicate the recipient through an aud claim or introspection response, and each resource server must verify that the token is intended for it. Scope and audience solve different problems: scope limits what the token can do; audience limits where it can be used.
A bearer token can be used by whoever holds it. If an API A token is accepted by API B, a leak at one service can expose another. RFC 9700 recommends restricting access tokens to a specific resource server or, if that is not possible, a small set. Issuing a recipient value is not enough unless the API validates it.
Combine resource and scope
| Control | Question answered | Example |
|---|---|---|
| Audience / resource | Which API may use this token? | https://orders.example/api |
| Scope | Which actions are allowed there? | orders:read |
If an app only reads orders, request a token for the orders API with the minimum read scope. The same scope string can have different meaning at another API. Avoid combining resources and scopes unless needed, because the authorization server must evaluate a broader permission combination.
Indicate a resource with resource
RFC 8707 defines the resource parameter so a client can identify the protected resource it intends to call. Its value is an absolute URI without a fragment, often the API base URI. Use the most specific URI accepted by the provider; avoid a query unless necessary.
POST /token HTTP/1.1
Host: auth.example
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=<authorization_code>
&resource=https%3A%2F%2Forders.example%2Fapi
&scope=orders%3AreadThis is illustrative. Check whether the authorization server supports RFC 8707 and which resource identifiers it accepts. It can restrict the issued token based on resource and policy, but the token audience does not have to be the exact input URI; a server may map it to another URI or internal identifier. A JWT access token may expose aud; an opaque token may convey audience through introspection. Token formats vary. Decoding a JWT is not enough to establish validity: the resource server must validate signature, issuer, expiry, audience, scope, and application permissions.
Configure and verify
Identify each API's protected-resource identifier and trusted authorization servers.
Choose the `resource` URI or provider-defined audience for the API actually called.
Request only the minimum scopes needed there; split tokens by resource unless there is a clear reason not to.
Confirm that the issued token is actually restricted. Adding `resource` to a request alone is not proof.
Verify each API rejects a token with a different audience; test cross-API use with non-sensitive resources.
When resource identifiers change, coordinate client configuration, token validation, and caches.
Common mistakes
Reducing scope but leaving the token usable at multiple APIs.
Confusing OAuth access-token audience with an OpenID Connect ID Token audience; they have different recipients and purposes.
Assuming a `resource` request guarantees the authorization server issued a restricted token.
Failing to check audience at the resource server.
Treating matching audience and scope as sufficient for every operation; also enforce object ownership and application authorization.
Summary
Audience restriction limits where an access token can be used; scope limits what it can do there. Request the exact resource and minimum scope, then verify that the authorization server issues the restriction and every resource server enforces it.
References
[RFC 9700 §2.3 — Access Token Privilege Restriction](https://www.rfc-editor.org/rfc/rfc9700.html#section-2.3)
[RFC 8707 — Resource Indicators for OAuth 2.0](https://www.rfc-editor.org/rfc/rfc8707.html)
[RFC 7662 — OAuth 2.0 Token Introspection](https://www.rfc-editor.org/rfc/rfc7662.html)
[RFC 9068 — JWT Profile for OAuth 2.0 Access Tokens](https://www.rfc-editor.org/rfc/rfc9068.html)