bitwarden

Crates.iobitwarden
lib.rsbitwarden
version1.0.0
sourcesrc
created_at2023-01-31 15:27:03.84128
updated_at2024-09-26 16:22:48.936002
descriptionBitwarden Secrets Manager SDK
homepagehttps://bitwarden.com
repositoryhttps://github.com/bitwarden/sdk
max_upload_size
id772764
size29,222
Bitwarden DevOps (bitwarden-devops-bot)

documentation

README

Bitwarden Secrets Manager SDK

A Rust client SDK to interact with the Bitwarden Secrets Manager. This is a beta release and might be missing some functionality.

Usage

[dependencies]
bitwarden = { "*", features = ["secrets"] }

Minimum Supported Rust Version

Rust 1.75 or higher.

Example

use bitwarden::{
    auth::login::AccessTokenLoginRequest,
    error::Result,
    secrets_manager::{secrets::SecretIdentifiersRequest, ClientSecretsExt},
    Client, ClientSettings, DeviceType,
};
use uuid::Uuid;

async fn test() -> Result<()> {
    // Use the default values
    let mut client = Client::new(None);

    // Or set your own values
    let settings = ClientSettings {
        identity_url: "https://identity.bitwarden.com".to_string(),
        api_url: "https://api.bitwarden.com".to_string(),
        user_agent: "Bitwarden Rust-SDK".to_string(),
        device_type: DeviceType::SDK,
    };
    let mut client = Client::new(Some(settings));

    // Before we operate, we need to authenticate with a token
    let token = AccessTokenLoginRequest {
        access_token: String::from(""),
        state_file: None,
    };
    client.auth().login_access_token(&token).await.unwrap();

    let org_id = SecretIdentifiersRequest {
        organization_id: Uuid::parse_str("00000000-0000-0000-0000-000000000000").unwrap(),
    };
    println!(
        "Stored secrets: {:#?}",
        client.secrets().list(&org_id).await.unwrap()
    );
    Ok(())
}
Commit count: 229

cargo fmt