10 breaking releases
new 0.11.0 | Mar 17, 2023 |
---|---|
0.9.0 | Dec 16, 2022 |
0.8.0 | Nov 30, 2022 |
0.4.0 | Jun 16, 2022 |
0.1.1 | Jan 25, 2022 |
#13 in Authentication
7,541 downloads per month
Used in 5 crates
260KB
6K
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–19MB
~373K SLoC