Skip to content

Commit eafba80

Browse files
fix(client): loosen auth header validation
1 parent 10cb284 commit eafba80

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

src/coingecko_sdk/_client.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,10 @@ def default_headers(self) -> dict[str, str | Omit]:
299299

300300
@override
301301
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
302-
if self.pro_api_key and headers.get("x-cg-pro-api-key"):
303-
return
304-
if isinstance(custom_headers.get("x-cg-pro-api-key"), Omit):
302+
if headers.get("x-cg-pro-api-key") or isinstance(custom_headers.get("x-cg-pro-api-key"), Omit):
305303
return
306304

307-
if self.demo_api_key and headers.get("x-cg-demo-api-key"):
308-
return
309-
if isinstance(custom_headers.get("x-cg-demo-api-key"), Omit):
305+
if headers.get("x-cg-demo-api-key") or isinstance(custom_headers.get("x-cg-demo-api-key"), Omit):
310306
return
311307

312308
raise TypeError(
@@ -618,14 +614,10 @@ def default_headers(self) -> dict[str, str | Omit]:
618614

619615
@override
620616
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
621-
if self.pro_api_key and headers.get("x-cg-pro-api-key"):
622-
return
623-
if isinstance(custom_headers.get("x-cg-pro-api-key"), Omit):
617+
if headers.get("x-cg-pro-api-key") or isinstance(custom_headers.get("x-cg-pro-api-key"), Omit):
624618
return
625619

626-
if self.demo_api_key and headers.get("x-cg-demo-api-key"):
627-
return
628-
if isinstance(custom_headers.get("x-cg-demo-api-key"), Omit):
620+
if headers.get("x-cg-demo-api-key") or isinstance(custom_headers.get("x-cg-demo-api-key"), Omit):
629621
return
630622

631623
raise TypeError(

0 commit comments

Comments
 (0)