Legacy Dev Forum Posts

 View Only

Sign Up

Client_credentials authentication type - error

  • 1.  Client_credentials authentication type - error

    Posted 06-05-2025 18:19

    ManjuR | 2021-05-26 15:30:25 UTC | #1

    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: { 'granttype': 'clientcredentials' } }; 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?


    jacobshaw | 2021-05-26 19:33:14 UTC | #2

    @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.


    Jerome.Saint-Marc | 2021-05-27 16:15:39 UTC | #3

    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,


    ManjuR | 2021-06-04 20:14:07 UTC | #4

    Thanks Jacob and Jerome, will check and confirm


    system | 2021-07-05 20:14:08 UTC | #5

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


    This post was migrated from the old Developer Forum.

    ref: 11028