1use flickr_api::{ApiKey, FlickrAPI};
2use std::error::Error;
3use std::io::{self, Write};
4
5fn prompt(message: &str) -> String {
6 let mut input = String::new();
8
9 print!("{message}");
11
12 io::stdout().flush().ok();
14
15 io::stdin()
17 .read_line(&mut input)
18 .expect("Failed to read line");
19
20 input.trim().to_string()
22}
23
24#[tokio::main]
25async fn main() -> Result<(), Box<dyn Error>> {
26 let client = FlickrAPI::new(ApiKey {
27 key: prompt("API key: "),
28 secret: prompt("API secret: "),
29 })
30 .login()
31 .await?;
32
33 let user = client.test().login().await?;
34
35 println!("Successfully logged in as {} ({})", user.username, user.id);
36
37 Ok(())
38}