Repository: spectacles-ci/spectacles

Issue:
Refreshing access token creates an infinite loop

Discussion:

Patch:
diff --git a/spectacles/client.py b/spectacles/client.py
index 306b851..c7652f9 100644
--- a/spectacles/client.py
+++ b/spectacles/client.py
@@ -86,7 +86,8 @@ class LookerClient:
 
         url = utils.compose_url(self.api_url, path=["login"])
         body = {"client_id": self.client_id, "client_secret": self.client_secret}
-        response = self.post(url=url, data=body, timeout=TIMEOUT_SEC)
+        # This should not use `self.post` or it will create a recursive loop
+        response = self.session.post(url=url, data=body, timeout=TIMEOUT_SEC)
         try:
             response.raise_for_status()
         except requests.exceptions.HTTPError:


Test patch:
diff --git a/tests/test_client.py b/tests/test_client.py
index 4693e72..51b265e 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -164,7 +164,7 @@ def test_bad_requests_should_raise_looker_api_errors(
         client_method(**client_kwargs[method_name])
 
 
-@patch("spectacles.client.LookerClient.post")
+@patch("spectacles.client.requests.Session.post")
 def test_authenticate_should_set_session_headers(mock_post, monkeypatch):
     mock_looker_version = Mock(spec=LookerClient.get_looker_release_version)
     mock_looker_version.return_value("1.2.3")