use fitbit_rs::access_token;
use std::env;
use std::process;
fn main() {
let access_token = match env::args().nth(1) {
Some(token) => token,
None => {
eprintln!("Usage: cargo run --example store_token -- YOUR_ACCESS_TOKEN");
process::exit(1);
}
};
match access_token::store_access_token(&access_token) {
Ok(_) => {
println!("Successfully stored access token!");
println!("You can now use the library without manually providing an access token.");
}
Err(err) => {
eprintln!("Failed to store access token: {}", err);
process::exit(1);
}
}
match access_token::get_access_token() {
Ok(token) => {
if token == access_token {
println!("Verified that the token was stored correctly.");
} else {
eprintln!("Warning: The retrieved token does not match the stored token!");
}
}
Err(err) => {
eprintln!("Failed to retrieve the stored access token: {}", err);
process::exit(1);
}
}
}