OAuth 2.0 Client Credentials Grant Flow
OAuth 2.0 Client Credentials Grant Flow is a protocol that allows applications to obtain an access token to access protected resources on behalf of themselves, rather than on behalf of a user. This flow is typically used for server-to-server communication, where the application needs to authenticate itself to access resources.
Flow Overview
Actors:
- Client: The application that wants to access the protected resource.
- Authorization Server: The server that issues access tokens to the client after successfully authenticating it.
- Resource Server: The server that hosts the protected resources and validates the access token.
OAuth Flow:
- The client authenticates itself with the authorization server using its client credentials (client ID and client secret).
- The authorization server validates the client’s credentials and, if valid, issues an access token to the client.
- The client uses the access token to access the protected resource on the resource server.
- The resource server validates the access token and, if valid, allows the client to access the requested resource.
Example Authentication Request from client to authorization server:
1 | POST /token HTTP/1.1 |
Example Response from authorization server to client:
1 | HTTP/1.1 200 OK |
Example Resource Request from client to resource server:
1 | GET /path/to/protected-resource HTTP/1.1 |
Example Response from resource server to client:
1 | HTTP/1.1 200 OK |