From 4318b31b1fc265699b8cbcd8c4a950b7048cbd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 17 Oct 2024 22:06:38 -0600 Subject: [PATCH] refactor: Override `authenticate_request` in `GitHubTokenAuthenticator` --- tap_github/authenticator.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tap_github/authenticator.py b/tap_github/authenticator.py index f934343..d873b77 100644 --- a/tap_github/authenticator.py +++ b/tap_github/authenticator.py @@ -359,24 +359,18 @@ def update_rate_limit( self.active_token.update_rate_limit(response_headers) - @property - def auth_headers(self) -> dict[str, str]: - """Return a dictionary of auth headers to be applied. - - These will be merged with any `http_headers` specified in the stream. - - Returns: - HTTP headers for authentication. - """ - result = super().auth_headers + def authenticate_request( + self, + request: requests.PreparedRequest, + ) -> requests.PreparedRequest: if self.active_token: # Make sure that our token is still valid or update it. if not self.active_token.has_calls_remaining(): self.get_next_auth_token() - result["Authorization"] = f"token {self.active_token.token}" + request.headers["Authorization"] = f"token {self.active_token.token}" else: self.logger.info( "No auth token detected. " "For higher rate limits, please specify `auth_token` in config." ) - return result + return request