SAP Knowledge Base Article - Public

3789226 - How To Configure OAuth 2.0 Client Credentials Authentication for an API User

Symptom

  • HTTP 401 Unauthorized is returned.
  • Error message: code “42000”, group “iamservice.root”, message “Either the username or the password is incorrect. Please try again with valid sign-in credentials.”

Environment

SAP Sales and Service Cloud Version 2

Reproducing the Issue

  1. Create a technical user configured for OAuth 2.0 Client Credentials for inbound communication.
  2. Attempt to retrieve an access token using the client credentials.
  3. Observe that the request fails with an authentication error.

Cause

The OAuth 2.0 Client Credentials flow requires specific configuration steps before an access token can be successfully generated.

Resolution

  1. Use the OAuth 2.0 token endpoint to request an access token
    • Method: POST
    • URL: https://tenantURL/oauth2/token

  2. Configure the Authorization
    • Type: Inherit Auth

  3. Configure the request headers
    • Authorization: Basic {Base64Encode(clientId:clientSecret)}
    • Content-Type: application/x-www-form-urlencoded

  4. Configure the request body
    • Body Type: x-www-form-urlencoded
    • Parameter: grant_type=client_credentials

  5. Send the request
    • If the configuration is correct, the system returns an OAuth 2.0 access token

Keywords

OAuth 2.0; OAuth2; Client Credentials; Client Credentials Flow; API User; API Client; Access Token; Token Endpoint; OAuth Token; Inbound Communication; Authentication; Authorization; Client ID; Client Secret; Base64 Encoding; Basic Authentication; POST Request; REST API; OData API; SAP Sales Cloud V2; SAP Service Cloud V2; SAP CX; API Authentication; Integration; System-to-System Integration; Bearer Token; HTTP Headers; Content-Type; grant_type=client_credentials; 401 Unauthorized , KBA , CEC-CRM-IAM , Identity and Access Management for SAP Sales/Service Cloud , How To

Product

SAP Sales Cloud and SAP Service Cloud Version 2 1.0