Skip to content

Commit

Permalink
chore(client): update new oauth path (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigaloid authored Sep 25, 2024
1 parent 1e54c63 commit 2d6ac78
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::time::{error::Elapsed, timeout};

static REDDIT_ANDROID_OAUTH_CLIENT_ID: &str = "ohXpoqrZYub1kg";

static AUTH_ENDPOINT: &str = "https://accounts.reddit.com";
static AUTH_ENDPOINT: &str = "https://www.reddit.com";

// Spoofed client for Android devices
#[derive(Debug, Clone, Default)]
Expand Down Expand Up @@ -68,7 +68,7 @@ impl Oauth {
}
async fn login(&mut self) -> Option<()> {
// Construct URL for OAuth token
let url = format!("{AUTH_ENDPOINT}/api/access_token");
let url = format!("{AUTH_ENDPOINT}/auth/v2/oauth/access-token/loid");
let mut builder = Request::builder().method(Method::POST).uri(&url);

// Add headers from spoofed client
Expand Down Expand Up @@ -98,6 +98,8 @@ impl Oauth {
// Parse headers - loid header _should_ be saved sent on subsequent token refreshes.
// Technically it's not needed, but it's easy for Reddit API to check for this.
// It's some kind of header that uniquely identifies the device.
// Not worried about the privacy implications, since this is randomly changed
// and really only as privacy-concerning as the OAuth token itself.
if let Some(header) = resp.headers().get("x-reddit-loid") {
self.headers_map.insert("x-reddit-loid".to_owned(), header.to_str().ok()?.to_string());
}
Expand Down

0 comments on commit 2d6ac78

Please sign in to comment.