Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Override authenticate_request in GitHubTokenAuthenticator #321

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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