Crates.io | yubico_otp |
lib.rs | yubico_otp |
version | 0.1.0 |
source | src |
created_at | 2023-06-28 19:44:50.184395 |
updated_at | 2023-06-28 19:44:50.184395 |
description | A library for verifying Yubico OTPs |
homepage | |
repository | https://github.com/eternal-flame-AD/yubico_otp_rs |
max_upload_size | |
id | 902729 |
size | 65,272 |
Yubikey validation Protocol 2.0 client implementation in Rust.
use yubico_otp::{client::Client, params::ApiCredentials, params::ValidationOption};
use std::process::ExitCode;
#[tokio::main]
async fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let creds = ApiCredentials::from_base64_secret(
"your_client_id".into(),
"your_base64_secret_key",
)?;
let client = Client::new(&client, creds);
let opt = ValidationOption::default();
let (status, resp) = client
.verify(std::env::args().nth(1).expect("OTP missing"), &opt)
.await?;
eprintln!("Status: {:?}", status);
eprintln!("Response: {:?}", resp);
Ok(if status.is_ok() {
ExitCode::SUCCESS
} else {
ExitCode::FAILURE
})
}