Issue with Unauthorized Client Error in Genesys Cloud SDK Example

Hi,

I'm working on a simple application using the Genesys Cloud SDK (purecloud-platform-client-v2), and I've encountered an error that I need help troubleshooting. Despite the app functioning correctly with AWS connections etc, I'm facing an issue specific to Genesys Cloud API interactions.

Environment Details:

  • Node.js Version: v20.10.0
  • Genesys Cloud SDK Version: ^185.0.0

Error Encountered: While trying to authenticate using the client credentials grant, the app throws the following error:

AxiosError: Request failed with status code 400
error: 'unauthorized_client',
description: 'client is not authorized to use the client_credential grant type',
error_description: 'client is not authorized to use the client_credential grant type'


**Sample Code:**

javascriptCopy code


const platformClient = require('purecloud-platform-client-v2');
const client = platformClient.ApiClient.instance;
// Credentials redacted
const CLIENT_ID = 'xxx';
const CLIENT_SECRET = 'xxx';
client.setEnvironment(platformClient.PureCloudRegionHosts.eu_west_1);
let organizationApi = new platformClient.OrganizationApi();

console.log('Getting Ready');

client.loginClientCredentialsGrant(CLIENT_ID, CLIENT_SECRET)
  .then(() => {
    organizationApi.getOrganizationsMe()
      .then((data) => {
        console.log(`getOrganizationsMe success! data: ${JSON.stringify(data, null, 2)}`);
      })
      .catch((err) => {
        console.error('Error calling getOrganizationsMe', err);
      });
  });

``

Given that this setup works well with AWS, is there any other reason besides the OAuth client configuration that might cause this error with Genesys Cloud?

Any insights or suggestions would be greatly appreciated.

---

Hello,

This error means that you indeed have an OAuth Client configured in your Genesys Cloud organization with this same clientId, but with a different Grant Type than Client Credentials.

So I think the OAuth Client you are leveraging has been defined with a different Grant Type than the one you are trying to invoke (Client Credentials Grant).
You probably have to create another OAuth Client wth Client Crdentials Grant Type (Genesys Cloud config).

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.