Get client secret and key #5
36
src/lib.rs
Normal file
36
src/lib.rs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
use std::error::Error;
|
||||||
|
use std::fs::read_to_string;
|
||||||
|
|
||||||
|
pub fn run() -> Result<(), Box<dyn Error>> {
|
||||||
|
let client_auth = read_client_auth()?;
|
||||||
|
|
||||||
|
println!("Client ID: {}", client_auth.client_id);
|
||||||
|
println!("Client Secret: {}", client_auth.client_secret);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ClientAuth {
|
||||||
|
client_id: String,
|
||||||
|
client_secret: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_client_auth() -> Result<ClientAuth, Box<dyn Error>> {
|
||||||
|
let mut id = String::new();
|
||||||
|
let mut secret = String::new();
|
||||||
|
|
||||||
|
for line in read_to_string(".client-auth")?.lines() {
|
||||||
|
let line_str = line.to_string();
|
||||||
|
let cur_line: Vec<&str> = line_str.split('=').collect();
|
||||||
|
if cur_line[0] == "client_id" {
|
||||||
|
id = cur_line[1].to_string();
|
||||||
|
} else if cur_line[0] == "client_secret" {
|
||||||
|
secret = cur_line[1].to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(ClientAuth {
|
||||||
|
client_id: id,
|
||||||
|
client_secret: secret,
|
||||||
|
})
|
||||||
|
}
|
||||||
10
src/main.rs
Normal file
10
src/main.rs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
use std::process;
|
||||||
|
|
||||||
|
use tsdproxy_keygen::run;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if let Err(e) = run() {
|
||||||
|
println!("An error occured: {e}");
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user