oauth/
oauth.rs

1use std::time::Duration;
2
3//ZEEBE_AUTHENTICATION_MODE=identity docker compose up -d
4//URL: http://localhost:26500
5//Client ID: zeebe
6//Client secret: zecret
7//OAuth URL: http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token
8//Audience: zeebe-api
9#[tokio::main]
10async fn main() -> Result<(), Box<dyn std::error::Error>> {
11    unsafe { std::env::set_var("RUST_BACKTRACE", "1") };
12    let client = zeebe_rs::Client::builder()
13        .with_address("http://localhost", 26500)
14        .with_oauth(
15            String::from("zeebe"),
16            String::from("zecret"),
17            String::from(
18                "http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token",
19            ),
20            String::from("zeebe-api"),
21            Duration::from_secs(30),
22            None,
23        )
24        .build()
25        .await?;
26
27    let _ = client.auth_initialized().await;
28    let topology = client.topology().send().await;
29    println!("{:?}", topology);
30
31    Ok(())
32}