SAML SSO breaks client credentials grant?

We just flipped SAML SSO for the org and my Node.js service stopped getting tokens via POST /oauth/token.

const client = new PlatformClient.ApiClient();
client.postOAuthApiToken({
credentials: { username: ‘svc-bot’, password: ‘secret’ }
});

It throws a 401 Unauthorized now. Do I need to switch to a different grant type or is the service account just disabled?

Enabling SAML SSO often triggers a global security policy update that disables password grants for service accounts by default. It’s not that the account is disabled, but the grant type password is blocked for non-interactive logins. You’ll need to switch to the client_credentials grant. This requires an OAuth Client ID and Secret generated in the Developer Console.

First, go to Developer Console > Applications and create a new OAuth Client. Set the grant type to client_credentials and assign the necessary scopes (e.g., analytics:events:read). Note the Client ID and Secret.

Here is how you adjust the Node.js SDK configuration:

const PureCloudPlatformClientV2 = require('@genesyscloud/genesyscloud');

const config = {
 clientId: 'your-client-id',
 clientSecret: 'your-client-secret',
 basePath: 'https://api.mypurecloud.com'
};

const platformClient = PureCloudPlatformClientV2.ApiClient.instance;
platformClient.init(config);

// No username/password needed here
platformClient.loginClientCredentials(config.clientId, config.clientSecret, ['analytics:events:read']);

// Now your API calls will work
const analyticsClient = new PureCloudPlatformClientV2.AnalyticsApi();

If you are tracking latency with New Relic, wrap the loginClientCredentials call. The handshake is slightly different from password grants, and you might see a small delta in token acquisition time. Also, ensure the service account still has the required roles. SSO enablement doesn’t strip roles, but it’s a common oversight.

The 401 error is specifically because the password grant is now forbidden for that identity context. Switching to client_credentials resolves it. Just make sure you rotate the secret if it was exposed in logs earlier.