Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit cd09b4b

Browse files
committed
allow specifying shared totp secret in login example
1 parent 349541d commit cd09b4b

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

examples/login.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env::args;
22
use std::error::Error;
33
use steam_vent::auth::{
44
AuthConfirmationHandler, ConsoleAuthConfirmationHandler, DeviceConfirmationHandler,
5-
FileGuardDataStore,
5+
FileGuardDataStore, SharedSecretAuthConfirmationHandler,
66
};
77
use steam_vent::proto::steammessages_player_steamclient::CPlayer_GetOwnedGames_Request;
88
use steam_vent::{Connection, ConnectionSender, ServerList};
@@ -14,16 +14,32 @@ async fn main() -> Result<(), Box<dyn Error>> {
1414
let mut args = args().skip(1);
1515
let account = args.next().expect("no account");
1616
let password = args.next().expect("no password");
17+
// base64 encoded
18+
let guard_secret = args.next();
1719

1820
let server_list = ServerList::discover().await?;
19-
let connection = Connection::login(
20-
&server_list,
21-
&account,
22-
&password,
23-
FileGuardDataStore::user_cache(),
24-
ConsoleAuthConfirmationHandler::default().or(DeviceConfirmationHandler),
25-
)
26-
.await?;
21+
let connection = match guard_secret {
22+
Some(secret) => {
23+
Connection::login(
24+
&server_list,
25+
&account,
26+
&password,
27+
FileGuardDataStore::user_cache(),
28+
SharedSecretAuthConfirmationHandler::new(&secret),
29+
)
30+
.await?
31+
}
32+
None => {
33+
Connection::login(
34+
&server_list,
35+
&account,
36+
&password,
37+
FileGuardDataStore::user_cache(),
38+
ConsoleAuthConfirmationHandler::default().or(DeviceConfirmationHandler),
39+
)
40+
.await?
41+
}
42+
};
2743

2844
println!("requesting games");
2945

0 commit comments

Comments
 (0)