Skip to main content

Client Credentials

Cloud has the newest features. Some may not be in a release yet; the newest release is Identity & Access Management 7.3.0.

The Client Credentials grant (RFC 6749 §4.4) is the machine-to-machine flow. A backend service authenticates with its own credentials at the token endpoint and receives an access token that represents the service itself, with no user context, no redirect, and no browser.

Use it for service-to-service calls, internal daemons, scheduled jobs, and CLI tools that act under a system identity rather than on behalf of a user.

How It Works​

How Choreo Identity & Access Management Implements It
AspectBehavior
EndpointPOST /oauth2/token
Grant typeclient_credentials
Client typeIntended for confidential clients that authenticate with their own credentials
Token subjectsub in the issued access token is the client_id
End-user attributesNot included: there is no authenticated user
Client attributesThe client's own attributes can be added as subject claims via clientConfig.attributes. OU claims (ouId, ouName, ouHandle), groups, and roles are available to any client; agents can also include their schema attributes, system attributes (name, owner), and sub_valid_until, when their lifespan ends in Unix seconds. All are opt-in and must be listed explicitly.
Subject classsub_type carries application or agent, so a resource server can apply policy that differs by identity class. Selected through clientConfig.attributes, and added there when the client is created, so a new client carries it without configuration. Clear the sub_type chip on the Console Token tab to drop it. Its value always comes from the server's record of the client's class
Refresh tokenNot issued for this grant (re-request when needed)
Scope filteringRequested scopes are filtered to permissions defined on the target resource server, then intersected with the permissions the client holds through its role and group assignments
aud claimThe supplied resource server identifier, or defaultResourceServer for a permission-bearing request without resource. A scopeless request without resource uses the application's token.accessToken.defaultAudience, falling back to client_id
ID tokenNot issued: this is an OAuth-only flow, not OIDC
note

OU claims are opt-in: a client receives only the claims it lists in clientConfig.attributes. Select them in the Console under Access token attributes: on an application's Token tab with Application selected under Issued to, or on an agent's Tokens tab with Agent selected.

info

sub_type is added to clientConfig.attributes when a client is created, so a new client carries the claim without configuration. This covers the Console, dynamic client registration, and resources imported with target: runtime, all of which create the client through the same service.

A client that is only ever read from a declarative file, that is, one served by an application or agent store running in declarative mode, is never created through that path, so it has to list the claim itself:

resource_type: application
name: Reporting Service
type: m2m
ouHandle: default
inboundAuthConfig:
- type: oauth2
config:
grantTypes:
- client_credentials
token:
accessToken:
clientConfig:
attributes:
- sub_type

Leaving it out is a valid choice, not an error: the client simply receives no sub_type. The same applies to a client created before the claim existed, which carries it once the chip is selected on the Token tab. A resource server should therefore treat a missing sub_type as an unknown identity class rather than assuming one.

Try It in Choreo Identity & Access Management​

  1. Open Applications or Agents in the Choreo Identity & Access Management Console and select your client.
  2. Open the Advanced tab.
  3. Under Grant types, select client_credentials.
  4. Choose a confidential Token Endpoint Authentication method (see Client Authentication Methods).
  5. Assign the roles or groups that grant the permissions the service should hold: these determine the scopes it can be issued.
  6. Save.
note

When requesting permission scopes, the client must include resource unless defaultResourceServer is configured globally. A scopeless request does not require either setting and uses the application's token.accessToken.defaultAudience (falling back to client_id) as its audience.

Request a Token​

curl -X POST https://<DATA_PLANE_URL>/oauth2/token \
-u "$CLIENT_ID:$CLIENT_SECRET" \
-d "grant_type=client_credentials" \
-d "scope=reservations:create" \
-d "resource=https://api.example.com/booking"

Response:

{
"access_token": "eyJhbGciOiJSUzI1NiI...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "reservations:create"
}
Deploy your changes

Saving a change does not make it live. You author in the control plane, and your users sign in on a separate data plane, so a change takes effect in an environment only after you deploy it. Go to Deploy, deploy the latest version to your first environment, then promote it to the next environment when you are ready.

Auto-sync deploys saved changes to your first environment within seconds. Turning it on is your choice, per project. See Deploy a Version, or learn why you deploy and how auto-sync works.

Was this page helpful?