Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions sdk/identity/examples/client_credentials_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ async fn main() -> Result<(), Box<dyn Error>> {
let client_secret =
env::var("CLIENT_SECRET").expect("Missing CLIENT_SECRET environment variable.");
let tenant_id = env::var("TENANT_ID").expect("Missing TENANT_ID environment variable.");
let subscription_id =
env::var("SUBSCRIPTION_ID").expect("Missing SUBSCRIPTION_ID environment variable.");
let scope = env::var("SCOPE").expect("Missing SCOPE environment variable.");

let http_client = azure_core::new_http_client();
// This will give you the final token to use in authorization.
let token = client_credentials_flow::perform(
http_client.clone(),
&client_id,
&client_secret,
&["https://management.azure.com/"],
&[&scope],
&tenant_id,
)
.await?;
println!("Non interactive authorization == {token:?}");

let subscription_id =
env::var("SUBSCRIPTION_ID").expect("Missing SUBSCRIPTION_ID environment variable.");

// Let's enumerate the Azure SQL Databases instances
// in the subscription. Note: this way of calling the REST API
// will be different (and easier) using other Azure Rust SDK
Expand Down
6 changes: 3 additions & 3 deletions sdk/identity/src/client_credentials_flow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
//! let client_secret =
//! env::var("CLIENT_SECRET").expect("Missing CLIENT_SECRET environment variable.");
//! let tenant_id = env::var("TENANT_ID").expect("Missing TENANT_ID environment variable.");
//! let subscription_id =
//! env::var("SUBSCRIPTION_ID").expect("Missing SUBSCRIPTION_ID environment variable.");
//! let scope =
//! env::var("SCOPE").expect("Missing SCOPE environment variable.");
//!
//! let http_client = azure_core::new_http_client();
//! // This will give you the final token to use in authorization.
//! let token = client_credentials_flow::perform(
//! http_client.clone(),
//! &client_id,
//! &client_secret,
//! &["https://management.azure.com/"],
//! &[&scope],
//! &tenant_id,
//! )
//! .await?;
Expand Down