Issue with Optimize API Token Authentication on Local Self-Managed Cluster

Hello Camunda community,

I am currently facing an issue while attempting to use the Optimize API on my local self-managed Camunda cluster, and I would appreciate any guidance or assistance from the community.

Problem Description:

I am encountering difficulties with the Optimize authentication token obtained from the following endpoint: http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token

Key Points:

  1. I have confirmed the use of the correct client_secret and client_id in my token request.

  2. I have experimented both with and without specifying the audience: optimize-api parameter in the token request.

  3. Write permissions for the Optimize API have been granted in the Identity settings.

  4. Surprisingly, attempts to authorize any request to the Optimize API using the acquired token result in a status 401 error.

Additional Information:

All other APIs within the local Camunda cluster are functioning as expected.

I have only experienced this issue when running a local cluster on my Windows 11 machine. Our Camunda SaaS or AKS clusters, on the other hand, do not exhibit this problem.

If anyone has encountered a similar problem or has insights into potential solutions, I would greatly appreciate your assistance. Thank you in advance for your time and support.

Best regards,

Kristoffer Högberg

Hi @kristofferph, welcome to the forums! Can you share how you’ve configured your client in Identity, with all the associated permissions? Did you deploy Camunda to AKS with a different configuration than locally?

Hi @nathan.loding,

Thank you for the reply!

To clarify, I am using a different configuration on the local self-managed cluster (I’m using the standard full docker compose) which is only intended for testing purposes, however I do need to access the Optimize api on the local cluster.

Below are screenshots of how I configured my token request in Postman (which works as expected with the Operate, Zeebe, and tasklist APIs) and the relevant permissions in Identity.

I have noticed that the client_secret seems to be hard-coded, since it is the same across all the APIs; that might be the root of this issue, since the the other apis are working?

To verify the cluster and optimize, I included a screenshot of a successful request to /api/readyz, which does not require any authorization.

I reached out to the Camunda support team, and I’m pleased to share that I’ve received a solution that successfully addresses the issue.

I will paste their response below:

"I have checked the Optimize config, and the reason for the 401 response is that the API token is not set.

For Optimize, you don’t request the token from keycloak, but instead you need to explicitly set a static token with the environment variable OPTIMIZE_API_ACCESS_TOKEN. Then you need to use that token for every REST API request.

For more details, please refer to: Overview | Camunda 8 Docs
and
Docker | Camunda 8 Docs

For example you add the environment variable in your docker compose like this:

environment:
- OPTIMIZE_API_ACCESS_TOKEN=secrettoken
Then you will need to use “secrettoken” as your Authorization Bearer in your request headers."

I have verified that this works!

Hi @kristofferph - I don’t think you should need a static access token. I am waiting on some information from the engineering team, but I believe there’s a solution to make it work with Identity.

Hi @nathan.loding,

Thanks for the update! I appreciate you checking in with the engineering team.
Looking forward to hearing more about a potential alternative solution.

Cheers

@kristofferph - you should be able to use the jwtSetUri and audience environment variables/configuration options to configure Optimize to work with Identity. I’m not sure if the URL comes from Identity or Keycloak, but the audience value should match whatever you configured for the application inside Identity. I am going to continue to work on getting more details and updating our docs. If you experiment with it and find a configuration that works, please let me know!

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