Skip to content

Commit

Permalink
refactor: Override authenticate_request in GitHubTokenAuthenticator
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Oct 18, 2024
1 parent 88b779d commit 4318b31
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tap_github/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4318b31

Please sign in to comment.