part 2OAuth 2.1 from scratch·lesson 2.6 of 10·2 min read
The client credentials grant: machines without a user
The OAuth 2.1 client credentials grant is how a client obtains an access token when there is no human to ask. This lesson explains when to use client credentials instead of the authorization code grant, what the token request looks like, and the security requirements that come with it, including how MCP authorization covers this case.
In this lesson
Decide when to use client credentials instead of authorization code.
Read and write a client credentials token request.
Explain its security requirements and why it needs a confidential client.
When there is nobody to ask
Sometimes the client does not act on behalf of any person: a nightly job that queries an MCP server, a backend agent, another service. There is no browser and no consent screen. The client authenticates with its own credentials and receives the token directly.
Usually without a refresh token: when the access token expires, the client simply asks for a new one.
3. Use
Client (service) → MCP server
Same as always: Authorization: Bearer ….
Authorization code vs. client credentials
Authorization code + PKCE
Client credentials
Is there a user?
Yes
No
Browser
Yes
No
The token represents…
The user (through the app)
The application itself
Client type
Public or confidential
Confidential only (must keep a secret)
Refresh token
Common
Usually not
Summary
No user → client credentials: the token is issued directly in exchange for the client's own credentials.
Only for confidential clients (they must be able to keep a secret); usually no refresh token is issued.
The client authenticates with client_secret, or better, with private_key_jwt or mTLS.
quiz · 3 questions
1. A desktop app you distribute to thousands of users wants to use client credentials with an embedded secret. Good idea?
Client credentials requires a confidential client. A secret shipped inside a distributed app is not secret. Distributed apps should use authorization code + PKCE.
2. What does an access token obtained with client credentials represent?
There is no user in this grant: the client authenticates with its own credentials and the token represents the application.
3. A client credentials access token expires. What does the client typically do?
This grant usually issues no refresh token; the client just repeats the token request with its own credentials.