CXone Client Credentials Grant 401 Error

  • Node.js 18
  • CXone REST API v2
  • HTTP Status 401

Why does this setting fail to return a valid access token?

const res = await fetch('https://api.nice.incontact.com/oauth/token', {
 method: 'POST',
 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
 body: new URLSearchParams({ grant_type: 'client_credentials', client_id: 'X', client_secret: 'Y' })
});

The response is always {"error":"invalid_grant"}.