use composio_sdk::client::ComposioClient;
use composio_sdk::config::ComposioConfig;
use composio_sdk::models::internal::Internal;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("COMPOSIO_API_KEY")
.expect("COMPOSIO_API_KEY environment variable not set");
println!("=== Composio SDK Internal Realtime Credentials Example ===\n");
let config = ComposioConfig {
api_key,
..Default::default()
};
let client = Arc::new(ComposioClient::from_config(config)?);
println!("✓ Client initialized\n");
let internal = Internal::new(client);
println!("Fetching SDK realtime credentials...");
match internal.get_sdk_realtime_credentials().await {
Ok(credentials) => {
println!("✓ Successfully retrieved realtime credentials\n");
println!("Credentials Details:");
println!(" Pusher Key: {}", credentials.pusher_key);
println!(" Project ID: {}", credentials.project_id);
println!(" Pusher Cluster: {}", credentials.pusher_cluster);
println!();
println!("These credentials can be used to establish WebSocket connections");
println!("for receiving real-time events from the Composio platform.");
}
Err(e) => {
eprintln!("✗ Failed to retrieve realtime credentials: {}", e);
return Err(e.into());
}
}
println!("\n=== Example completed successfully ===");
Ok(())
}