diff --git a/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py b/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py index e378945ae4adf..9fb2dfe342575 100644 --- a/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py +++ b/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py @@ -867,6 +867,7 @@ def _refresh_access_token(self) -> None: self._make_request( method="POST", endpoint="/applications/token", + base_url=self.api_base_url, data={ "client_id": self.client_id, "client_secret": self.client_secret, @@ -892,6 +893,7 @@ def _make_request( self, method: str, endpoint: str, + base_url: str, data: Optional[Mapping[str, Any]] = None, include_additional_request_params: bool = True, ) -> Mapping[str, Any]: @@ -900,6 +902,7 @@ def _make_request( Args: method (str): The http method to use for this request (e.g. "POST", "GET", "PATCH"). endpoint (str): The Airbyte API endpoint to send this request to. + base_url (str): The base url to the Airbyte API to use. data (Optional[Dict[str, Any]]): JSON-formatted data string to be included in the request. include_additional_request_params (bool): Whether to include authorization and user-agent headers to the request parameters. Defaults to True. @@ -907,7 +910,7 @@ def _make_request( Returns: Dict[str, Any]: Parsed json data from the response to this request """ - url = self.api_base_url + endpoint + url = base_url + endpoint headers = {"accept": "application/json"} num_retries = 0 diff --git a/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py b/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py index 36d0839d726cf..7ecfe585f09e8 100644 --- a/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py +++ b/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py @@ -27,7 +27,7 @@ def test_refresh_access_token(base_api_mocks: responses.RequestsMock) -> None: with mock.patch("dagster_airbyte.resources.datetime", wraps=datetime) as dt: # Test first call, must get the access token before calling the jobs api dt.now.return_value = test_time_first_call - client._make_request(method="GET", endpoint="/test") # noqa + client._make_request(method="GET", endpoint="/test", base_url=client.api_base_url) # noqa assert len(base_api_mocks.calls) == 2 access_token_call = base_api_mocks.calls[0] @@ -43,7 +43,7 @@ def test_refresh_access_token(base_api_mocks: responses.RequestsMock) -> None: # Test second call, occurs before the access token expiration, only the jobs api is called dt.now.return_value = test_time_before_expiration - client._make_request(method="GET", endpoint="/test") # noqa + client._make_request(method="GET", endpoint="/test", base_url=client.api_base_url) # noqa assert len(base_api_mocks.calls) == 1 jobs_api_call = base_api_mocks.calls[0] @@ -55,7 +55,7 @@ def test_refresh_access_token(base_api_mocks: responses.RequestsMock) -> None: # Test third call, occurs after the token expiration, # must refresh the access token before calling the jobs api dt.now.return_value = test_time_after_expiration - client._make_request(method="GET", endpoint="/test") # noqa + client._make_request(method="GET", endpoint="/test", base_url=client.api_base_url) # noqa assert len(base_api_mocks.calls) == 2 access_token_call = base_api_mocks.calls[0]