OAuth Client Credentials Grant: get service tokens without a user
Learn when Client Credentials fits, how a service gets a token, and how to protect its credentials and application permissions.
OAuth Client Credentials Grant: get service tokens without a user
The OAuth Client Credentials Grant lets a backend service or automation authenticate as itself and obtain an API access token without acting for a user. RFC 6749 permits this grant only for confidential clients. Do not embed a client secret in a browser or mobile app that cannot keep it confidential. This grant does not replace user login or consent.
The basic flow
The service client sends a request to the authorization server's token endpoint.
The request includes `grant_type=client_credentials` and, when needed, a limited `scope`.
The client authenticates using a registered method, such as a client secret or a certificate-based method the provider supports.
The server checks the client identity and permitted scope, then issues an access token.
The client sends the token to the resource server, which allows or denies the API request according to the client's permissions.
There is no user browser redirect or separate consent screen at the authorization endpoint. RFC 6749 describes limiting scope to resources controlled by the client or agreed in advance with the authorization server. The token therefore represents application permissions, not permissions delegated by a person. RFC 9700 recommends that when a token has a subject (sub), it identify the client application, and that resource servers distinguish client identity from user identity.
When it fits
A backend calls another API within a defined scope.
A batch job, monitor, or scheduled sync runs as a particular service.
Automation accesses client-owned resources without user interaction.
If access must vary by user or reach personal data, do not use Client Credentials as a user-delegation flow. Consider the authorization code grant or another suitable delegation method from the provider. The resource server must distinguish user-authorized tokens from application-authorized tokens.
Operational security checks
**Protect secrets.** Manage client secrets in a server-side secret store; keep them out of source code, frontend bundles, container images, and logs. RFC 6749 says not to issue client credentials to native or user-agent clients that cannot keep them confidential.
**Request the minimum scope.** Separate permissions by service or task so one application account does not have unrestricted API access.
**Limit token lifetime and exposure.** Do not write access tokens to logs, URLs, or user-visible screens; send them over TLS. If credentials leak, rotate or revoke them and revoke affected tokens.
**Choose client authentication.** If supported by the authorization server, consider mutual TLS (mTLS) certificate-based client authentication. RFC 8705 defines mTLS client authentication and certificate-bound access tokens. Check actual algorithms and settings in the server documentation.
**Validate token type and subject.** The resource server should check issuer, target API (audience), expiry, scope or role, and client subject. Do not confuse user and application tokens.
**Monitor behavior.** Detect unexpected client logins, excessive token issuance, or unusual API scopes and call patterns; prepare a credential-rotation procedure.
RFC 6749 says refresh tokens SHOULD NOT normally be issued for Client Credentials Grant. Provider behavior can differ, so document how the service obtains new tokens and manages long-lived secrets. For sensitive APIs, design client authentication for token issuance together with authorization checks at the API.
References
[RFC 6749: The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html)
[RFC 9700: Best Current Practice for OAuth 2.0 Security](https://www.rfc-editor.org/rfc/rfc9700.html)
[RFC 8705: OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens](https://www.rfc-editor.org/rfc/rfc8705.html)