2 unstable releases

0.2.0 May 29, 2023
0.1.0 Mar 21, 2021

#514 in Authentication

Download history 36/week @ 2023-12-05 36/week @ 2023-12-12 34/week @ 2023-12-19 33/week @ 2023-12-26 47/week @ 2024-01-02 36/week @ 2024-01-09 36/week @ 2024-01-16 35/week @ 2024-01-23 39/week @ 2024-01-30 29/week @ 2024-02-06 45/week @ 2024-02-13 79/week @ 2024-02-20 63/week @ 2024-02-27 54/week @ 2024-03-05 64/week @ 2024-03-12 42/week @ 2024-03-19

234 downloads per month

MIT license

17KB
286 lines

b2creds

CI Docs Crates.io

b2creds is a simple library built to access the credentials for BackBlaze APIs. It mimics the access patterns of the b2 CLI tool and thus should work on any machine where a user has logged in with the b2 CLI.

By default, b2creds will search in the following locations:

  1. In the B2_APPLICATION_KEY and B2_APPLICATION_KEY_ID environmentals variables

  2. In the sqlite database pointed to by the environmental variable B2_ACCOUNT_INFO

  3. In the default sqlite database ~/.b2_account_info

let creds = b2creds::Credentials::locate().unwrap();
println!("Key ID: {} Key: {}", creds.application_key_id, creds.application_key);

lib.rs:

This crate contains the logic to read B2 credentials following the same logic used by the B2 CLI.

let creds = b2creds::Credentials::locate().unwrap();
println!("Key ID: {} Key: {}", creds.application_key_id, creds.application_key);

Look at the Credentials::locate, Credentials::from_env. and Credentials::from_file to understand how to parse B2 credentials.

Dependencies

~22–32MB
~484K SLoC