Skip to content

Commit

Permalink
Pass through extra headers on every request. (#2510)
Browse files Browse the repository at this point in the history
* Pass through extra headers on every request.

* Preserve Python 2 compatibility and refactor dict unpacking

Co-authored-by: Michael Liu <miliu@protonmail.com>

Co-authored-by: Michael Liu <miliu@protonmail.com>
  • Loading branch information
lsb and convoliution committed Jul 27, 2021
1 parent b713ced commit 3a90c13
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/verta/verta/client.py
Expand Up @@ -80,6 +80,8 @@ class Client(object):
Whether to use a local Git repository for certain operations such as Code Versioning.
debug : bool, default False
Whether to print extra verbose information to aid in debugging.
extra_auth_headers : dict, default {}
Extra headers to include on requests, like to permit traffic through a restrictive application load balancer
_connect : str, default True
Whether to connect to server (``False`` for unit tests).
Expand Down Expand Up @@ -117,7 +119,7 @@ class Client(object):
"""
def __init__(self, host=None, port=None, email=None, dev_key=None,
max_retries=5, ignore_conn_err=False, use_git=True, debug=False, _connect=True):
max_retries=5, ignore_conn_err=False, use_git=True, debug=False, extra_auth_headers={}, _connect=True):
self._load_config()

if host is None and 'VERTA_HOST' in os.environ:
Expand All @@ -138,7 +140,8 @@ def __init__(self, host=None, port=None, email=None, dev_key=None,

if host is None:
raise ValueError("`host` must be provided")
auth = {_utils._GRPC_PREFIX+'source': "PythonClient"}
auth = extra_auth_headers.copy()
auth.update({_utils._GRPC_PREFIX+'source': "PythonClient"})
if email is None and dev_key is None:
if debug:
print("[DEBUG] email and developer key not found; auth disabled")
Expand Down

0 comments on commit 3a90c13

Please sign in to comment.