Blog post: OIDC third parties: client credentials, consent, and scope design
Choose the right grant
Use authorization code when an end user delegates access to an application. Use client credentials only when a machine or service acts as itself and no end user is involved.
Do not use client_credentials as a shortcut for user-delegated access. Its token subject is the client ID, not a user; downstream services cannot make user-specific authorization decisions from it.
Register machine clients narrowly
A machine-client registration should include only the grant, scopes, and audiences it needs:
{
"clientId": "sample-m2m",
"grantTypes": ["client_credentials"],
"scopes": ["api:read"],
"audiences": ["app-api"]
}
Provider-side policy should enforce:
- confidential machine clients authenticate with HTTP Basic client authentication
- client secrets in form bodies are rejected
- public clients cannot use
client_credentials - secrets are generated or rotated by the provider and shown once
- unsupported grant types and arbitrary scope strings are rejected
audienceidentifies the target API; scope identifies the capability
Understand what consent records
Consent applies to user-delegated flows, not machine-to-machine flows. There is no user in client_credentials, so there is nothing meaningful for a consent screen to record.
For authorization-code clients, a consent screen should:
- hide protocol plumbing such as
openid - explain scopes in user language
- separate newly requested scopes from previously approved scopes
- treat
offline_accessexplicitly because it means refresh tokens - store consent per user and client
- support incremental approval when a client later asks for additional scopes
A consent page is not necessarily a consent-management console. If previously approved scopes are automatically carried forward, provide a separate revocation or account-management path.
Separate the questions scopes answer
Do not force one string namespace to mean everything.
| Scope type | Examples | Question answered |
|---|---|---|
| Identity scopes | profile, email, attributes | Which user claims may be exposed? |
| API capability scopes | api:read, api:write | What class of operation may the token perform? |
| Operational scopes | introspect | Which provider operation may this trusted client call? |
| Duration scope | offline_access | May the client receive refresh tokens? |
Audience is related but distinct:
aud = which resource server this token is for
scope = what the token may do there
The gateway or resource server should enforce both. A token with api:read but the wrong aud is still the wrong token.
Provider enforcement checklist
- Maintain an explicit allowlist of supported scopes and grant types.
- Require redirect URIs for authorization-code clients.
- Require HTTPS redirect URIs except loopback development addresses.
- Require PKCE for public authorization-code clients.
- Keep machine tokens free of user-specific claims.
- Register expected audiences and emit them in access tokens.
- Enforce route-specific audience and scope at the edge, then re-validate at the resource server when the downstream needs defense in depth.
- Record client lifecycle events such as creation, update, deletion, and secret rotation.
Gotchas
- Broad scopes such as
adminorfull_accessmake consent meaningless. - Very fine-grained scopes can explode into an unmaintainable permission catalog; keep scopes coarse and enforce object-level authorization downstream.
- Scope names are part of the trust contract. Renaming them is a compatibility-breaking change.
- Adding a new scope should trigger consent again when user delegation is involved.
- A scope should not encode a tenant, user, or object ID. Use claims and downstream authorization for that context.
- Refresh tokens are a credential-lifetime decision, not just another API permission; keep
offline_accessvisible.