🐛 fix: idk anymore
This commit is contained in:
parent
5ff48cace8
commit
f12eaf5bd8
4 changed files with 35 additions and 14 deletions
|
|
@ -16,7 +16,7 @@ pub const ID: &str = "org.polyfrost.launcher";
|
|||
pub const DISCORD_RPC_CLIENT_ID: &str = "1234567890000000";
|
||||
|
||||
/// Microsoft client ID.
|
||||
pub const MICROSOFT_CLIENT_ID: &str = "";
|
||||
pub const MICROSOFT_CLIENT_ID: &str = "00000000402b5328";
|
||||
/// Microsoft login redirect URI.
|
||||
pub const REDIRECT_URL: &str = "https://login.live.com/oauth20_desktop.srf";
|
||||
/// Microsoft login xboxlive scopes to get tokens.
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ use std::io::Write;
|
|||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use tauri::async_runtime::spawn_blocking;
|
||||
use tempfile::NamedTempFile;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
/// A wrapper around generic and unhelpful [`std::io::Error`] messages.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
|
|
|||
|
|
@ -14,3 +14,5 @@ authors = { workspace = true }
|
|||
onelauncher = { path = "../core", features = [ "cli" ] }
|
||||
|
||||
tokio = { workspace = true }
|
||||
webbrowser = { version = "0.8" }
|
||||
url = { version = "2.5" }
|
||||
|
|
|
|||
|
|
@ -5,24 +5,43 @@
|
|||
|
||||
use onelauncher::prelude::*;
|
||||
|
||||
pub async fn authenticate_mc() -> onelauncher::Result<MinecraftCredentials> {
|
||||
println!("a browser will open, follow login flow");
|
||||
let login = minecraft::begin().await?;
|
||||
|
||||
println!("url is {}", login.redirect_uri.as_str());
|
||||
webbrowser::open(login.redirect_uri.as_str())?;
|
||||
|
||||
println!("enter flow url: ");
|
||||
let mut input = String::new();
|
||||
std::io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("unable to read input");
|
||||
|
||||
println!("{}", input.trim());
|
||||
|
||||
let parsed = url::Url::parse(input.trim()).expect("idk");
|
||||
let code = if let Some((_, code)) = parsed.query_pairs().find(|x| x.0 == "code") {
|
||||
&code.clone()
|
||||
} else {
|
||||
panic!()
|
||||
};
|
||||
let creds = minecraft::finish(code, login).await?;
|
||||
|
||||
|
||||
println!("logged in {}", creds.username);
|
||||
Ok(creds)
|
||||
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> onelauncher::Result<()> {
|
||||
let _logger = onelauncher::start_logger();
|
||||
let state = State::get().await?;
|
||||
|
||||
if minecraft::users().await?.is_empty() {
|
||||
println!("logging in");
|
||||
let login = minecraft::begin().await?;
|
||||
|
||||
println!("{}", login.redirect_uri.as_str());
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("unable to read input");
|
||||
println!("{}", input.trim());
|
||||
let credentials = minecraft::finish(&input, login).await?;
|
||||
println!("{}", credentials.username);
|
||||
println!("authenticating");
|
||||
authenticate_mc().await?;
|
||||
}
|
||||
|
||||
state.settings.write().await.max_async_fetches = 100;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue