Skip to content

Commit

Permalink
Refresh OAuth on 401 only (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokarak authored Jan 28, 2024
1 parent 03e267f commit 3d2c936
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,12 @@ pub async fn json(path: String, quarantine: bool) -> Result<Value, String> {
}
}
Err(e) => {
error!("Got a bad response from reddit {e} - forcing a token refresh. Status code: {status}");
let () = force_refresh_token().await;
error!("Got a bad response from reddit {e}. Status code: {status}");
// Unauthorized; token expired
if status == 401 {
error!("Forcing a token refresh");
let () = force_refresh_token().await;
}
if status.is_server_error() {
Err("Reddit is having issues, check if there's an outage".to_string())
} else {
Expand Down

0 comments on commit 3d2c936

Please sign in to comment.