-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01ab507
commit 25662d1
Showing
20 changed files
with
378 additions
and
113 deletions.
There are no files selected for viewing
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,7 +1,37 @@ | ||
//! MSA authentication stages | ||
|
||
use futures::Future; | ||
use reqwest::Response; | ||
|
||
const RETRY_COUNT: usize = 2; // Does command 3 times | ||
const RETRY_WAIT: std::time::Duration = std::time::Duration::from_secs(2); | ||
|
||
pub mod bearer_token; | ||
pub mod player_info; | ||
pub mod poll_response; | ||
pub mod xbl_signin; | ||
pub mod xsts_token; | ||
|
||
#[tracing::instrument(skip(reqwest_request))] | ||
pub async fn auth_retry<F>( | ||
reqwest_request: impl Fn() -> F, | ||
) -> crate::Result<reqwest::Response> | ||
where | ||
F: Future<Output = Result<Response, reqwest::Error>>, | ||
{ | ||
let mut resp = reqwest_request().await?; | ||
for i in 0..RETRY_COUNT { | ||
if resp.status().is_success() { | ||
break; | ||
} | ||
tracing::debug!( | ||
"Request failed with status code {}, retrying...", | ||
resp.status() | ||
); | ||
if i < RETRY_COUNT - 1 { | ||
tokio::time::sleep(RETRY_WAIT).await; | ||
} | ||
resp = reqwest_request().await?; | ||
} | ||
Ok(resp) | ||
} |
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
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.