From 2f3daffa747d341351b3ab6e4ac84bbf05ecf0ee Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Fri, 14 Apr 2023 05:05:44 -0700 Subject: [PATCH] fix: authenticate in page_next/page_prev calls Fixes the following error: error err=Couldn't get next page Caused by: 0: Error encountered in the HTTP backend while requesting a route. 1: HTTP status client error (401 Unauthorized) for url (https://hachyderm.io/api/v1/timelines/home?max_id=110196530215835290) --- src/mastodon.rs | 2 +- src/page.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mastodon.rs b/src/mastodon.rs index 46f4b41..92744ed 100644 --- a/src/mastodon.rs +++ b/src/mastodon.rs @@ -381,7 +381,7 @@ impl Mastodon { } /// Set the bearer authentication token - fn authenticated(&self, request: RequestBuilder) -> RequestBuilder { + pub(crate) fn authenticated(&self, request: RequestBuilder) -> RequestBuilder { request.bearer_auth(&self.data.token) } diff --git a/src/page.rs b/src/page.rs index f7b95f7..9dcc418 100644 --- a/src/page.rs +++ b/src/page.rs @@ -26,7 +26,7 @@ macro_rules! pages { "making API request" ); let url: String = url.into(); // <- for logging - let response = self.mastodon.client.get(&url).send().await?; + let response = self.mastodon.authenticated(self.mastodon.client.get(&url)).send().await?; match response.error_for_status() { Ok(response) => { let (prev, next) = get_links(&response, self.call_id)?;