Apologies for the elementary inquiry, but the workforce management endpoint doesn’t accept my Python SDK initialization and throws a 401 Unauthorized error when pulling quality evaluation data. The token refresh mechanism stalls during the client credentials flow on SDK version 1.2.0, it’s completely ignoring the pagination headers, and the console output only prints the first traceback line. requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://mypurecloud.ie.genesys.cloud/api/v2/wfm/schedule/api/schedules
PureCloudPlatformClientV2 handles the token refresh automatically, so if you’re hitting a 401 on the quality endpoints, it’s almost always a scope mismatch or an expired refresh token stuck in the client cache. The client credentials flow doesn’t support refresh_token grants, which means your token expires after 3600 seconds and the SDK can’t renew it without a full re-auth. You’ll need to switch to authorization code with PKCE or make sure your client_credentials request explicitly includes wfm:evaluation:read.
Here’s how the Node SDK initializes it correctly without tripping over the auth flow:
const PureCloudPlatformClientV2 = require('@genesyscloud/genesyscloud');
const platformClient = PureCloudPlatformClientV2.create();
const authSettings = {
authMethod: 'clientCredentials',
clientId: process.env.GC_CLIENT_ID,
clientSecret: process.env.GC_CLIENT_SECRET,
scopes: ['wfm:evaluation:read', 'quality:read'],
apiRootUrl: 'https://api.mypurecloud.com'
};
platformClient.setAuthSettings(authSettings);
await platformClient.login();
Make sure you’re not mixing production tokens with sandbox credentials, that trips up half the integrations I see.
If you’re still getting that traceback, drop a console.log right before the API call to verify the Bearer token actually has a payload. The 401 usually means the header never attached properly. Also, pagination on /api/v2/wfm/evaluation/evaluations requires pageNumber and pageSize query params, not custom headers. The SDK wraps that in listWfmEvaluationEvaluations(convId, options).
Check your scope array first.