Open-messaging-blueprint-main, Request failed with status code 400

Hi,

I'm testing open messaging (open-messaging-blueprint-main) and can't log in with OAuth client.loginClientCredentialsGrant(config.clientId,config.clientSecret) get the error what could be the reason? details are correct in OAuth clientId and clientSecret.

AxiosError {message: 'Request failed with status code 400', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: ClientRequest, …}
The thread 'app.js [37860]' (0x0) has exited with code 0 (0x0).
The program 'JavaScript debug adapter: app.js [37860]' has exited with code 4294967295 (0xffffffff).
The program 'app.js' has exited with code 4294967295 (0xffffffff).

I use npm purecloud-platform-client-v2@185.0.0

/***************************************************

  • Authenticate with Genesys Cloud using an

  • OAuth Client Credentials Grant flow
    */
    function authenticate() {
    client.loginClientCredentialsGrant(config.clientId,config.clientSecret)
    .then((data)=> {
    // Do authenticated things
    accessToken = data.accessToken;

     // Start express on the defined port
     app.listen(PORT, () => {
         console.log(`Server listenign on local port ${PORT}`);
    
         // Start Local Tunnel for public internet access
         (async () => {
             const tunnel = await localtunnel({ 
                 port: PORT, 
                 subdomain: LT_SUBDOMAIN
             });
    
             console.log(`Server listening on external URL ${tunnel.url}`);
    
             tunnel.on('close', () => {
                 // tunnels are closed
             });
         })();
     });
    

    })
    .catch((err) => {
    // Handle failure response
    console.log(err);
    });
    }

/Lars

Hello,

If you have not updated the code already, you need to point to the correct Genesys Cloud region (region of your org).
The setEnvironment is missing in the sample code - and therefore uses mypurecloud.com as the default region.
If your org is in EMEA/Frankfurt (mypurecloud.de), you would set the region/environment as below:

function authenticate() {
    client.setEnvironment("mypurecloud.de");
    client.loginClientCredentialsGrant(config.clientId,config.clientSecret)
    .then((data)=> {

Regards,

1 Like

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