Zeebe Java Client 401 (From tutorial)

Hi

I can’t connect to my Zeebe Cloud cluster using the Java Client
I was reading this Java Client can't connect to Camunda Cloud Cluster · Issue #4356 · camunda/zeebe · GitHub but is not working for me :frowning:

Important: every variable to connect are fine, works from another integration.

My config
Gradle

implementation group: 'io.zeebe', name: 'zeebe-client-java', version: '0.26.6'

Java

OAuthCredentialsProvider credentialsProvider =
                new OAuthCredentialsProviderBuilder()
                        .authorizationServerUrl("https://login.cloud.camunda.io/oauth/token")
                        .audience("XXX.bru-2.zeebe.camunda.io:443")
                        .clientId("CLIENT_ID")
                        .clientSecret("CLIENT_SECRET")
                        .build();

        ZeebeClient client =
                ZeebeClient.newClientBuilder()
                        .credentialsProvider(credentialsProvider)
                        .gatewayAddress("XXX.bru-2.zeebe.camunda.io:443")
                        .build();

        final WorkflowInstanceResult processInstanceResult =
                client
                        .newCreateInstanceCommand()
                        .bpmnProcessId("Process_XXXXX")
                        .latestVersion()
                        .withResult() // to await the completion of process execution and return result
                        .send()
                        .join();

        System.out.println(
                "Process instance created with key: "
                        + processInstanceResult.getWorkflowKey()
                        + " and completed with results: "
                        + processInstanceResult.getVariables());

Thanks in advance

Hi @Gonzalo_Mendoza :wave:

I think the audience should be without :443.

Also note that, if you’re connecting to Camunda Cloud Saas, that from version 1.0 onwards you can use the dedicated ZeebeClient.newCloudClientBuilder() (see https://ZeebeClient.java#L57-L60), which creates the OAuthCredentialsProvider for you.

Hope it helps :smiley:

1 Like