IAM interview questions · Protocols
When do you use the client credentials grant?
In plain wordsTwo machines talking, no person involved: the service shows its own badge to get a ticket.
How it works
In the client credentials grant the client authenticates as itself at the token endpoint and receives an access token representing the application, not a user. There is no browser, no refresh token, no consent screen.
Client authentication matters: a shared client_secret works but leaks easily. Stronger options are private_key_jwt (the client signs an assertion with its private key) or mutual TLS. In cloud workloads, workload identity federation lets a pod or function get tokens without any stored secret.
A concrete example
A nightly billing job calls the invoices API. It requests a token with scope invoices:read, authenticating with private_key_jwt. The API sees sub = billing-job, not a person, and the logs show exactly which service did what. If the job is compromised, only invoices:read is exposed.
See it in action: a service calls an API
Mistakes to avoid
- Using client credentials to act on behalf of a user (that needs token exchange or the user flow).
- Secrets in code repositories that never rotate.
They may also ask you
- How would a service call another service on behalf of a user?
- How would you rotate client secrets without downtime?