Skip to content

Commit a60947d

Browse files
committed
Add support for custom auth header.
1 parent 144ec31 commit a60947d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

pypdns/api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class PyPDNS:
266266
def __init__(self, url: str='https://www.circl.lu/pdns/query',
267267
basic_auth: tuple[str, str] | None=None,
268268
auth_token: str | None=None,
269+
auth_header: tuple[str, str] | None=None,
269270
enable_cache: bool=False, cache_expire_after: int=604800,
270271
cache_file: str='/tmp/pdns.cache',
271272
https_proxy_string: str | None=None,
@@ -277,6 +278,7 @@ def __init__(self, url: str='https://www.circl.lu/pdns/query',
277278
:param url: The URL of the service
278279
:param basic_auth: HTTP basic auth to cnnect to the service: ("username", "password")
279280
:param auth_token: HTTP basic auth but the token
281+
:param auth_header: HTTP header to use for authentication: ("X-API-AUTH", "1234")
280282
:param enable_cache: Cache responses locally
281283
:param cache_file: The file to cache the responses to
282284
:param https_proxy_string: The HTTP proxy to connect to the service (deprecated, use proxies instead)
@@ -303,6 +305,8 @@ def __init__(self, url: str='https://www.circl.lu/pdns/query',
303305
self.session.auth = basic_auth
304306
elif auth_token is not None:
305307
self.session.headers.update({'Authorization': auth_token})
308+
elif auth_header is not None:
309+
self.session.headers.update({auth_header[0]: auth_header[1]})
306310
else:
307311
# No authentication defined.
308312
pass

0 commit comments

Comments
 (0)