Newman runs are suddenly choking on the OAuth flow (specifically the client credentials grant) and throwing a 401 Unauthorized even though the environment variables are correct. tbh, it’s doing jack all in Postman’s native runner but fails the second it hits the CLI.
The pre-request script is just a standard pm.sendRequest to the token endpoint (iirc, the logic hasn’t changed in months). imo, something shifted with how the token is being cached or passed in the header.
pm.sendRequest({
url: 'https://login.mypurecloud.com/oauth/token',
method: 'POST',
header: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: {
mode: 'urlencoded',
urlencoded: [
{ key: 'grant_type', value: 'client_credentials' },
{ key: 'client_id', value: pm.environment.get('client_id') },
{ key: 'client_secret', value: pm.environment.get('client_secret') }
]
}
}, function (err, res) {
pm.environment.set('access_token', res.json().access_token);
});