Files
Qlyra/third_party/kolibri/kolibri-net/examples/auth_verify.rs
T
sevenhill f74057ce9b
Build Android (FCM) / build-android-fcm (push) Canceled after 0s
Build Android / build-android (push) Canceled after 0s
Build iOS / build-ios (push) Canceled after 0s
Build Linux / build-linux (push) Canceled after 0s
Build macOS / build-macos (push) Canceled after 0s
Build Windows / build-windows (push) Canceled after 0s
Release (main) / android (oneme) (push) Canceled after 0s
Release (main) / android (qlyra) (push) Canceled after 0s
Release (main) / windows (push) Canceled after 0s
Release (main) / linux (push) Canceled after 0s
Release (main) / macos (push) Canceled after 0s
Release (main) / ios (push) Canceled after 0s
Release (main) / release (push) Canceled after 0s
Rebrand application as Qlyra
2026-08-30 13:16:17 +03:00

60 lines
2.2 KiB
Rust

//! Verify an OTP code using the temp token from the `auth_request` example.
//!
//! cargo run --example auth_verify -- <TOKEN> <CODE>
use std::time::Duration;
use kolibri_net::protocol::opcodes;
use kolibri_net::{ClientConfig, HandshakeConfig, Session, SessionConfig, UserAgent};
use rmpv::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut args = std::env::args().skip(1);
let token = args.next().ok_or("usage: auth_verify -- <TOKEN> <CODE>")?;
let code = args.next().ok_or("usage: auth_verify -- <TOKEN> <CODE>")?;
let handshake = HandshakeConfig {
instance_id: "i1e9c0de-0000-4000-8000-kolibri0001".to_string(),
device_id: "d1e9c0de-0000-4000-8000-kolibri0001".to_string(),
client_session_id: 1_700_000_000,
user_agent: UserAgent {
device_type: "ANDROID".to_string(),
app_version: "26.20.2".to_string(),
os_version: "Android 14".to_string(),
timezone: "Europe/Moscow".to_string(),
screen: "420dpi 420dpi 1080x2340".to_string(),
push_device_type: "GCM".to_string(),
arch: "arm64-v8a".to_string(),
locale: "ru".to_string(),
build_number: 6758,
device_name: "Xiaomi 23127PN0CG".to_string(),
device_locale: "ru".to_string(),
is_pwa: None,
header_user_agent: None,
},
};
let mut config = SessionConfig::new(ClientConfig::new("api.oneme.ru", 443), handshake);
config.auto_reconnect = false;
println!("→ connecting …");
let session = Session::new(config);
tokio::time::timeout(Duration::from_secs(20), session.connect()).await??;
println!("✓ online, verifying code …");
let verify = Value::Map(vec![
(Value::from("token"), Value::from(token)),
(Value::from("verifyCode"), Value::from(code)),
(Value::from("authTokenType"), Value::from("CHECK_CODE")),
]);
let mut buf = Vec::new();
rmpv::encode::write_value(&mut buf, &verify).unwrap();
let resp = session.request(opcodes::AUTH, &buf).await?;
println!("✓ response (cmd={}):\n{}", resp.cmd, resp.value()?);
session.disconnect();
Ok(())
}