Skip to content

Commit

Permalink
allow specifying shared totp secret in login example
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Oct 28, 2024
1 parent 349541d commit cd09b4b
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions examples/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::env::args;
use std::error::Error;
use steam_vent::auth::{
AuthConfirmationHandler, ConsoleAuthConfirmationHandler, DeviceConfirmationHandler,
FileGuardDataStore,
FileGuardDataStore, SharedSecretAuthConfirmationHandler,
};
use steam_vent::proto::steammessages_player_steamclient::CPlayer_GetOwnedGames_Request;
use steam_vent::{Connection, ConnectionSender, ServerList};
Expand All @@ -14,16 +14,32 @@ async fn main() -> Result<(), Box<dyn Error>> {
let mut args = args().skip(1);
let account = args.next().expect("no account");
let password = args.next().expect("no password");
// base64 encoded
let guard_secret = args.next();

let server_list = ServerList::discover().await?;
let connection = Connection::login(
&server_list,
&account,
&password,
FileGuardDataStore::user_cache(),
ConsoleAuthConfirmationHandler::default().or(DeviceConfirmationHandler),
)
.await?;
let connection = match guard_secret {
Some(secret) => {
Connection::login(
&server_list,
&account,
&password,
FileGuardDataStore::user_cache(),
SharedSecretAuthConfirmationHandler::new(&secret),
)
.await?
}
None => {
Connection::login(
&server_list,
&account,
&password,
FileGuardDataStore::user_cache(),
ConsoleAuthConfirmationHandler::default().or(DeviceConfirmationHandler),
)
.await?
}
};

println!("requesting games");

Expand Down

0 comments on commit cd09b4b

Please sign in to comment.