From de61aebbbb8eabd757de19e77328a5a027dcca30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Mon, 23 Sep 2024 11:50:01 -0600 Subject: [PATCH] chore: Use a single session to handle authentication steps in DummyJSON --- samples/sample_tap_dummy_json/tap_dummyjson/auth.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/auth.py b/samples/sample_tap_dummy_json/tap_dummyjson/auth.py index 4f21f432f..613d9a7aa 100644 --- a/samples/sample_tap_dummy_json/tap_dummyjson/auth.py +++ b/samples/sample_tap_dummy_json/tap_dummyjson/auth.py @@ -20,6 +20,7 @@ def __init__(self, auth_url, refresh_token_url, username, password): self.refresh_token = None self.expires = 0 + self.session = requests.Session() def __call__(self, request): if not self.refresh_token: @@ -45,13 +46,13 @@ def _handle_response(self, response): response.raise_for_status() data = response.json() - self.token = data["token"] + self.token = data["accessToken"] self.refresh_token = data["refreshToken"] self.expires = time.time() + EXPIRES_IN_MINS * 60 logger.info("Authenticated") def refresh(self): - response = requests.post( + response = self.session.post( self.refresh_token_url, json={ "refreshToken": self.refresh_token, @@ -61,7 +62,7 @@ def refresh(self): self._handle_response(response) def auth(self): - response = requests.post( + response = self.session.post( self.auth_url, json={ "username": self.username,