16 breaking releases
0.17.0 | Nov 3, 2023 |
---|---|
0.16.0 | Sep 28, 2023 |
0.13.0 | Jun 28, 2023 |
0.11.0 | Mar 17, 2023 |
0.1.1 | Jan 25, 2022 |
#2 in #azure
46,641 downloads per month
Used in 10 crates
290KB
6.5K
SLoC
azure_identity
Azure Identity crate for the unofficial Microsoft Azure SDK for Rust. This crate is part of a collection of crates: for more information please refer to https://github.com/azure/azure-sdk-for-rust. This crate provides mechanisms for several ways to authenticate against Azure
For example, to authenticate using the recommended DefaultAzureCredential
, you can do the following:
use azure_core::auth::TokenCredential;
use azure_identity::{DefaultAzureCredential};
use url::Url;
use std::env;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let credential = DefaultAzureCredential::default();
let response = credential
.get_token("https://management.azure.com")
.await?;
let subscription_id = env::var("AZURE_SUBSCRIPTION_ID")?;
let url = Url::parse(&format!(
"https://management.azure.com/subscriptions/{}/providers/Microsoft.Storage/storageAccounts?api-version=2019-06-01",
subscription_id))?;
let response = reqwest::Client::new()
.get(url)
.header("Authorization", format!("Bearer {}", response.token.secret()))
.send()
.await?
.text()
.await?;
println!("{:?}", response);
Ok(())
}
The supported authentication flows are:
This crate also includes utilities for handling refresh tokens and accessing token credentials from many different sources.
License: MIT
Dependencies
~8–24MB
~383K SLoC