From 6da4f8146252e2bb47bf8641417c81e45a7dd63b Mon Sep 17 00:00:00 2001
From: Jared Deckard <jared@shademaps.com>
Date: Tue, 26 Apr 2022 23:20:47 -0500
Subject: [PATCH 1/3] Allow the oauth host to be inferred safely

---
 docusign_esign/client/api_client.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/docusign_esign/client/api_client.py b/docusign_esign/client/api_client.py
index ae786b14..35fc02ac 100644
--- a/docusign_esign/client/api_client.py
+++ b/docusign_esign/client/api_client.py
@@ -804,17 +804,19 @@ def set_oauth_host_name(self, oauth_host_name=None):
             self.oauth_host_name = oauth_host_name
             return
 
-        if not oauth_host_name:
-            raise ArgumentException('oAuthBasePath cannot be empty')
+        if not self.base_path:
+            raise ArgumentException('Unable to infer oauth_host_name without base_path set')
 
         # Derive OAuth Base Path if not given
         if self.base_path.startswith("https://demo") or self.base_path.startswith("http://demo"):
             self.oauth_host_name = OAuth.DEMO_OAUTH_BASE_PATH
         elif self.base_path.startswith("https://stage") or self.base_path.startswith("http://stage"):
             self.oauth_host_name = OAuth.STAGE_OAUTH_BASE_PATH
-        else:
+        elif self.base_path.startswith("https://docusign") or self.base_path.startswith("http://docusign"):
             self.oauth_host_name = OAuth.PRODUCTION_OAUTH_BASE_PATH
 
+        raise ArgumentException('Unable to infer oauth_host_name from unknown base_path')
+
     def set_access_token(self, token_obj):
         """
 

From 8256757e960ba55820a21a53a7ab10559e214f14 Mon Sep 17 00:00:00 2001
From: Jared Deckard <jared@shademaps.com>
Date: Tue, 26 Apr 2022 23:27:25 -0500
Subject: [PATCH 2/3] Validate oauth_host_name before use and improve error
 messages

---
 docusign_esign/client/api_client.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/docusign_esign/client/api_client.py b/docusign_esign/client/api_client.py
index 35fc02ac..73c5c4e9 100644
--- a/docusign_esign/client/api_client.py
+++ b/docusign_esign/client/api_client.py
@@ -756,7 +756,7 @@ def get_user_info(self, access_token):
             raise ArgumentException("Cannot find a valid access token."
                                     " Make sure OAuth is configured before you try again.")
         if not self.oauth_host_name:
-            raise ArgumentException("oAuthBasePath cannot be empty")
+            raise ArgumentException("The oauth_host_name property has not been set")
 
         resource_path = '/oauth/userinfo'
         headers = {"Authorization": "Bearer " + access_token}
@@ -774,6 +774,8 @@ def generate_access_token(self, client_id, client_secret, code):
         """
         if not client_id or not client_secret or not code:
             raise ArgumentException
+        if not self.oauth_host_name:
+            raise ArgumentException("The oauth_host_name property has not been set")
         url = "https://{0}/oauth/token".format(self.oauth_host_name)
         integrator_and_secret_key = b"Basic " + base64.b64encode(str.encode("{}:{}".format(client_id, client_secret)))
         headers = {

From 7f609d1a49281204d5852127d18848240f9c67de Mon Sep 17 00:00:00 2001
From: Jared Deckard <jared@shademaps.com>
Date: Tue, 26 Apr 2022 23:33:04 -0500
Subject: [PATCH 3/3] Add todos for breaking interface changes on redundant
 args

---
 docusign_esign/client/api_client.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docusign_esign/client/api_client.py b/docusign_esign/client/api_client.py
index 73c5c4e9..b1b834d8 100644
--- a/docusign_esign/client/api_client.py
+++ b/docusign_esign/client/api_client.py
@@ -679,6 +679,7 @@ def request_jwt_user_token(self, client_id, user_id, oauth_host_name, private_ke
             raise ArgumentException("Private key not supplied or is invalid!")
         if not user_id:
             raise ArgumentException("User Id not supplied or is invalid!")
+        # TODO: Make oauth_host_name optional and default to the instance property.
         if not oauth_host_name:
             raise ArgumentException("oAuthBasePath cannot be empty")
 
@@ -720,6 +721,7 @@ def request_jwt_application_token(self, client_id, oauth_host_name, private_key_
 
         if not private_key_bytes:
             raise ArgumentException("Private key not supplied or is invalid!")
+        # TODO: Make oauth_host_name optional and default to the instance property.
         if not oauth_host_name:
             raise ArgumentException("oAuthBasePath cannot be empty")