1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! An example to send a password reset email by session-based interface.
//!
//! ```shell
//! $ cargo run --example send_password_reset_email -- --email <email>
//! ```
use clap::Parser;
use fars::ApiKey;
use fars::Config;
use fars::Email;
#[derive(Parser)]
struct Arguments {
#[arg(short, long)]
email: String,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Parse the command line arguments.
let arguments = Arguments::parse();
// Read API key from the environment variable.
let api_key = ApiKey::new(std::env::var("FIREBASE_API_KEY")?);
// Create a config.
let config = Config::new(api_key);
// Send a password reset email.
config
.send_reset_password_email(
Email::new(arguments.email.clone()),
None,
)
.await?;
println!(
"Succeeded to send a password reset email to {}",
arguments.email
);
Ok(())
}