Skip to content

Commit 5a0b89b

Browse files
fix(client): loosen auth header validation
1 parent 83d1c4a commit 5a0b89b

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/anthropic/_client.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,10 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
187187
# valid
188188
return
189189

190-
if self.api_key and headers.get("X-Api-Key"):
191-
return
192-
if isinstance(custom_headers.get("X-Api-Key"), Omit):
190+
if headers.get("X-Api-Key") or isinstance(custom_headers.get("X-Api-Key"), Omit):
193191
return
194192

195-
if self.auth_token and headers.get("Authorization"):
196-
return
197-
if isinstance(custom_headers.get("Authorization"), Omit):
193+
if headers.get("Authorization") or isinstance(custom_headers.get("Authorization"), Omit):
198194
return
199195

200196
raise TypeError(
@@ -431,14 +427,10 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
431427
# valid
432428
return
433429

434-
if self.api_key and headers.get("X-Api-Key"):
435-
return
436-
if isinstance(custom_headers.get("X-Api-Key"), Omit):
430+
if headers.get("X-Api-Key") or isinstance(custom_headers.get("X-Api-Key"), Omit):
437431
return
438432

439-
if self.auth_token and headers.get("Authorization"):
440-
return
441-
if isinstance(custom_headers.get("Authorization"), Omit):
433+
if headers.get("Authorization") or isinstance(custom_headers.get("Authorization"), Omit):
442434
return
443435

444436
raise TypeError(

0 commit comments

Comments
 (0)