diff --git a/pyproject.toml b/pyproject.toml index 78dd0f3..474b790 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ ] dependencies = [ - "requests >=2.26.0", + "requests[socks] >=2.26.0", ] [project.urls] diff --git a/src/pihole6api/conn.py b/src/pihole6api/conn.py index 455b796..c37c98d 100644 --- a/src/pihole6api/conn.py +++ b/src/pihole6api/conn.py @@ -63,8 +63,9 @@ def __init__(self, base_url, password, max_retries=3, retry_delay=1, # Set timeout self.session.timeout = connection_timeout - # Authenticate upon initialization - self._authenticate() + if password is not None and password != '': + # Authenticate upon initialization + self._authenticate() def _authenticate(self): """Authenticate with the Pi-hole API and store session ID and CSRF token. @@ -115,6 +116,9 @@ def _authenticate(self): def _get_headers(self): """Return headers including the authentication SID and CSRF token.""" + if self.password is None or self.password == '': + return {} + if not self.session_id or not self.csrf_token: self._authenticate() @@ -228,4 +232,4 @@ def exit(self): # Close the session to release connections self.session.close() - return response \ No newline at end of file + return response