-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_providers_for_email.rs
48 lines (40 loc) · 1.18 KB
/
fetch_providers_for_email.rs
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
44
45
46
47
48
//! An example to fetch ID providers for specified email by session-based interface.
//!
//! ```shell
//! $ cargo run --example fetch_providers_for_email -- --email <email>
//! ```
use clap::Parser;
use fars::ApiKey;
use fars::Config;
use fars::Email;
use fars::OAuthContinueUri;
#[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::from_env()?;
// Create a config.
let config = Config::new(api_key);
// Fetch ID providers for specified email.
let providers = config
.fetch_providers_for_email(
Email::new(arguments.email.clone()),
OAuthContinueUri::new("http://localhost"),
)
.await?;
// NOTE:
// Because email enumeration protection is enabled by default,
// the response may be `None`.
// See also the issue: https://github.com/firebase/firebase-ios-sdk/issues/11810
println!(
"Succeeded to fetch ID providers for email: {:?}",
providers
);
Ok(())
}