Skip to content

Commit c825565

Browse files
committed
Remove headers from init
1 parent 488377c commit c825565

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/openhound_github/auth.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def __init__(
5151
self.private_key_path = private_key_path
5252
self.client = RESTClient(
5353
base_url=self.api_uri,
54-
headers=self.jwt_headers,
5554
paginator=HeaderLinkPaginator(),
5655
)
5756

@@ -100,6 +99,7 @@ def token(self) -> TokenResponse:
10099
response = self.client.post(
101100
f"{self.api_uri}app/installations/{self.installation_id}/access_tokens",
102101
timeout=10,
102+
headers=self.jwt_headers,
103103
)
104104
response.raise_for_status()
105105
return TokenResponse(**response.json())
@@ -120,14 +120,16 @@ def __init__(
120120
@property
121121
def installations(self) -> Iterator[InstallationResponse]:
122122
for page in self.client.paginate(
123-
"/app/installations", params={"per_page": 100}
123+
"/app/installations", params={"per_page": 100}, headers=self.jwt_headers
124124
):
125125
for item in page:
126126
yield InstallationResponse(**item)
127127

128128
def install_id_for_org(self, org_login: str) -> int:
129129
logger.info(f"Getting app installation ID for org {org_login}")
130-
response = self.client.get(f"/orgs/{org_login}/installation")
130+
response = self.client.get(
131+
f"/orgs/{org_login}/installation", headers=self.jwt_headers
132+
)
131133
response.raise_for_status()
132134
return int(response.json()["id"])
133135

@@ -155,7 +157,11 @@ def _should_refresh(self) -> bool:
155157
return datetime.now(timezone.utc) >= refresh_at
156158

157159
def token(self, force_refresh: bool = False) -> str | None:
158-
if not force_refresh and self.access_token is not None and not self._should_refresh():
160+
if (
161+
not force_refresh
162+
and self.access_token is not None
163+
and not self._should_refresh()
164+
):
159165
return self.access_token
160166

161167
with self._token_lock:

0 commit comments

Comments
 (0)