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
  • audience identifies the target API; scope identifies the capability

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_access explicitly 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 typeExamplesQuestion answered
Identity scopesprofile, email, attributesWhich user claims may be exposed?
API capability scopesapi:read, api:writeWhat class of operation may the token perform?
Operational scopesintrospectWhich provider operation may this trusted client call?
Duration scopeoffline_accessMay 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 admin or full_access make 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_access visible.