OAuth 2.0 Client Credentials Flow

OAuth 2.0 Client Credentials Flow

This flow involves making an HTTP POST request to the OAuth 2.0 token endpoint to get access_tokenwith client credentials

Request Body:

  • grant_type=client_credentials

    • Specifies the type of grant being used. In this case, it is the client credentials grant.
  • client_id=1example23456789

    • The unique identifier of the client application requesting the token.
  • client_secret=9example87654321

    • The client application's secret, used to authenticate the client with the authorization server.

Authorize endpoint

curl --location 'https://ram-integration-api.auth.eu-central-1.amazoncognito.com/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=1example23456789' \
--data-urlencode 'client_secret=9example87654321'

Example – POST request

POST /oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
X-Amz-Target: AWSCognitoIdentityProviderService.Client credentials request
User-Agent: USER_AGENT
Accept: /
Accept-Encoding: gzip, deflate, br
Content-Length: 177
Referer: http://auth.example.com/oauth2/token
Host: auth.example.com
Connection: keep-alive

grant_type=client_credentials&client_id=1example23456789&scope=my_resource_server_identifier%2Fmy_custom_scope&client_secret=9example87654321

Example - Response

{
  "access_token":"eyJra1example", 
  "token_type":"Bearer", 
  "expires_in":3600
}

Access Token must be sent in Authorization header.