Legacy Dev Forum Posts

 View Only

Sign Up

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

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

    Posted 06-05-2025 18:37

    lars.karlsson | 2023-12-18 19:46:37 UTC | #1

    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: 'ERRBADREQUEST', 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


    Jerome.Saint-Marc | 2024-01-02 15:50:28 UTC | #2

    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,


    system | 2024-02-01 15:50:53 UTC | #3

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


    This post was migrated from the old Developer Forum.

    ref: 23767