-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of onboarding + New Launcher Auth
- Loading branch information
1 parent
ef8b525
commit c10477a
Showing
31 changed files
with
182 additions
and
3,697 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,21 @@ | ||
//! Login route for Hydra, redirects to the Microsoft login page before going to the redirect route | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::{hydra::MicrosoftError, util::fetch::REQWEST_CLIENT}; | ||
use super::{MICROSOFT_CLIENT_ID, REDIRECT_URL, REQUESTED_SCOPES}; | ||
|
||
use super::{stages::auth_retry, MICROSOFT_CLIENT_ID}; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct DeviceLoginSuccess { | ||
pub device_code: String, | ||
pub user_code: String, | ||
#[derive(Serialize, Deserialize)] | ||
pub struct AuthInit { | ||
pub verification_uri: String, | ||
pub expires_in: u64, | ||
pub interval: u64, | ||
pub message: String, | ||
} | ||
|
||
pub async fn init() -> crate::Result<DeviceLoginSuccess> { | ||
// Get the initial URL | ||
// Get device code | ||
// Define the parameters | ||
|
||
// urlencoding::encode("XboxLive.signin offline_access")); | ||
let resp = auth_retry(|| REQWEST_CLIENT.get("https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode") | ||
.header("Content-Length", "0") | ||
.query(&[ | ||
("client_id", MICROSOFT_CLIENT_ID), | ||
( | ||
"scope", | ||
"XboxLive.signin XboxLive.offline_access profile openid email", | ||
), | ||
]) | ||
.send() | ||
).await?; | ||
pub async fn init() -> AuthInit { | ||
let url = format!( | ||
"https://login.live.com/oauth20_authorize.srf?client_id={MICROSOFT_CLIENT_ID}&response_type=code&redirect_uri={}&scope={}&prompt=select_account&cobrandid=8058f65d-ce06-4c30-9559-473c9275a65d", | ||
urlencoding::encode(REDIRECT_URL), | ||
urlencoding::encode(REQUESTED_SCOPES), | ||
); | ||
|
||
match resp.status() { | ||
reqwest::StatusCode::OK => Ok(resp.json().await?), | ||
_ => { | ||
let microsoft_error = resp.json::<MicrosoftError>().await?; | ||
Err(crate::ErrorKind::HydraError(format!( | ||
"Error from Microsoft: {:?}", | ||
microsoft_error.error_description | ||
)) | ||
.into()) | ||
} | ||
AuthInit { | ||
verification_uri: url, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.