Client_credentials authentication type - error

Hi,

We are trying to use client_credentials authentication type to authenticate on Purecloud on server side.

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://login.mypurecloud.com/oauth/token',
'headers': {
'Authorization': 'Basic XXXXXXXXXXXXX',
'content-type': 'application/x-www-form-urlencoded',
'cache-control': 'no-cache'
},
form: {
'grant_type': 'client_credentials'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response);
});

But getting the following exception:
if (error) throw new Error(error);
** ^**
Error: Error: read ECONNRESET

What could be the issue?

@ManjuR
I'm getting a token back successfully using your code.
Ensure that you're encoding your credentials with base 64 for the Authorization header.
Here's a how-to for that: https://developer.genesys.cloud/api/rest/authorization/base-64-encoding
If that fails, and the credentials are valid, it will be something outside this code snippet that is causing the connection reset.

Hello,

Not that I have much to add to what Jacob said :slight_smile:
But reading your other post (works from postman web, not from postman desktop client), could it be that your enterprise has a proxy server for internet connections? Configured/enabled in your web browser (which would explain why postman web worked) and that you didn't take it into account in your postman desktop client configuration (and in your nodejs code).

Regards,

Thanks Jacob and Jerome, will check and confirm

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