Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is the Client Credentials Flow?

The client credentials flow is the OAuth 2.0 grant for machine-to-machine access: an application authenticates as itself, with no user present, and receives an access token.

Illustration for the cybersecurity term Client Credentials Flow
Home / Blog / Cybersecurity Terms / What Is the Client Credentials Flow?
17 November 2026

What Is the Client Credentials Flow?

What Is the Client Credentials Flow?

Most OAuth 2.0 grants exist to get a user’s permission. The client credentials flow exists because sometimes there is no user. A nightly reconciliation job, a payments service calling a ledger service, a monitoring agent pulling metrics—none of these can show a consent screen to anyone, and none should be running under a staff member’s account.

The flow is the simplest in the specification. The client posts its own credentials to the token endpoint with grant_type=client_credentials, the authorisation server checks them, and an access token comes back. One request, one response, no redirects, no browser.

How the Exchange Works

A request looks like this, with the client identifier and secret presented either in the body or using HTTP Basic authentication:

POST /oauth2/token HTTP/1.1
Host: login.example.co.uk
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id=svc-reconciliation
&client_secret=REDACTED
&scope=ledger.read ledger.reconcile

The response carries an access token, a token type, and an expiry in seconds. There is no refresh token, and there should not be: the client already holds credentials that let it mint a new access token whenever it needs one. A refresh token would add a second long-lived secret for no benefit.

Critically, the token represents the application, not a person. Its subject claim is the client identifier. Any resource server that assumes sub is a human user will make incorrect authorisation decisions the first time a service account calls it, and that mistake has produced real privilege escalation in APIs that shared authorisation code between user and machine callers.

The Shared Secret Problem

A client secret is a long-lived bearer credential, and it behaves exactly like a password that nobody rotates. Secrets end up in configuration files, in container images, in CI/CD variables, in a wiki page from 2022, and in public repositories. GitHub’s secret scanning programme detects millions of exposed credentials a year, and OAuth client secrets are a well-represented category.

Two better options exist, and both are widely supported:

Where a secret is unavoidable, remove it from your own storage entirely. Managed identities in Azure, IAM roles for service accounts in AWS and Google Cloud, and SPIFFE identities in Kubernetes all give a workload a credential it never has to hold on disk. Where you genuinely must hold one, it belongs in a vault with rotation, as covered in secrets management.

Scoping, Because Machines Accumulate Privilege Too

Machine clients suffer the same drift as human accounts, with less scrutiny. A service registered in 2021 to read invoices is granted write access for one migration and keeps it. Nobody reviews it, because reviews are aimed at people.

Register one client per workload rather than one per team, request the narrowest scopes that the job needs, and use the audience parameter so a token issued for the ledger API is rejected by the payments API. Keep access token lifetimes short—minutes, not hours—since the client can always request another. Include machine clients in your access review cycle with a named technical owner, and treat an unowned client as a candidate for disablement.

Getting the Deployment Right

Three operational details separate a sound implementation from a fragile one. First, cache tokens. A client that requests a fresh token for every API call will hit rate limits on the authorisation server and generate log volume that hides real anomalies; request once, reuse until shortly before expiry. Second, handle rotation without downtime by supporting two active credentials at once, so you can introduce the new key before retiring the old one. Third, log and alert on client credential grants from unexpected source addresses, since a stolen secret used from a different network is one of the few detectable signals you get.

Finally, resist the temptation to use this flow for anything that does involve a user. If a person is present, use the authorisation code flow with PKCE; a machine token with broad scopes acting on behalf of users is a common and consequential design error.

At Privia Security, we test machine-to-machine authorisation and token handling in our web application security services.

FAQ – Frequently Asked Questions

When Should I Not Use the Client Credentials Flow?

Whenever a user is involved. If the request is made on someone’s behalf, use the authorisation code flow with PKCE so the token carries that person’s identity and permissions. Using client credentials in a user-facing application means every action is attributed to the application, you lose per-user authorisation, and the audit trail cannot tell you who did what.

Why Is There No Refresh Token?

Because the client already holds credentials that let it obtain a new access token at any time. A refresh token would be a second long-lived secret with no additional benefit and an additional theft surface. If your library expects one, the correct behaviour is to request a fresh access token from the token endpoint when the current one nears expiry.

How Do I Avoid Storing a Client Secret?

Use platform workload identity where the cloud provider issues short-lived credentials that never touch your configuration: managed identities in Azure, IAM roles for service accounts in AWS or Google Cloud, or SPIFFE identities in Kubernetes. Where the authorisation server supports it, private key JWT or mutual TLS client authentication also removes the shared secret from the exchange entirely.

What Scopes Should a Machine Client Get?

Only the ones the specific workload calls, and no more. Register a separate client per workload rather than one per team, set the audience so a token for one API is rejected by another, and keep lifetimes to a few minutes. Then review machine clients on the same schedule as privileged user accounts, with a named technical owner for each.

Related Terms

You May Be Interested In These

What Is a Dictionary Attack?

Cybersecurity Terms

17 November 2026

What Is a Dictionary Attack?

Read More
What Are Kerberos Ticket Lifetimes?

Cybersecurity Terms

17 November 2026

What Are Kerberos Ticket Lifetimes?

Read More
What Is Spring4Shell?

Cybersecurity Terms

17 November 2026

What Is Spring4Shell?

Read More