Skip to content

Commit 6cebe55

Browse files
committed
updates/tweaks for check_connection
1 parent 544829c commit 6cebe55

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

airbyte/_util/api_util.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,17 +750,21 @@ def get_bearer_token(
750750
"""Get a bearer token.
751751
752752
https://reference.airbyte.com/reference/createaccesstoken
753+
753754
"""
754755
path = api_root + "/applications/token"
755756
headers: dict[str, str] = {
756757
"content-type": "application/json",
757758
"accept": "application/json",
758759
}
759760
request_body: dict[str, str] = {
760-
"grant-type": "client_credentials",
761+
"grant_type": "client_credentials",
761762
"client_id": client_id,
762763
"client_secret": client_secret,
763764
}
765+
# if "api.airbyte" not in api_root:
766+
# request_body["grant_type"] = "client_credentials"
767+
764768
response = requests.request(
765769
method="POST",
766770
url=path,
@@ -785,10 +789,10 @@ def check_connector(
785789
) -> tuple[bool, str | None]:
786790
"""Check a source.
787791
788-
Raises an exception if the check fails.
792+
Raises an exception if the check fails. Uses one of these endpoints:
789793
790-
https://github.com/airbytehq/airbyte-platform-internal/blob/10bb92e1745a282e785eedfcbed1ba72654c4e4e/oss/airbyte-api/server-api/src/main/openapi/config.yaml#L1409
791-
https://github.com/airbytehq/airbyte-platform-internal/blob/10bb92e1745a282e785eedfcbed1ba72654c4e4e/oss/airbyte-api/server-api/src/main/openapi/config.yaml#L1995
794+
- /v1/sources/check_connection: https://github.com/airbytehq/airbyte-platform-internal/blob/10bb92e1745a282e785eedfcbed1ba72654c4e4e/oss/airbyte-api/server-api/src/main/openapi/config.yaml#L1409
795+
- /v1/destinations/check_connection: https://github.com/airbytehq/airbyte-platform-internal/blob/10bb92e1745a282e785eedfcbed1ba72654c4e4e/oss/airbyte-api/server-api/src/main/openapi/config.yaml#L1995
792796
"""
793797
_ = workspace_id # Not used (yet)
794798
bearer_token: SecretString = get_bearer_token(

tests/integration_tests/cloud/test_cloud_api_util.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ def test_get_bearer_token(
263263
@pytest.mark.parametrize(
264264
"connector_id, connector_type, expect_success",
265265
[
266-
("0f766e9e-636e-4687-8483-f2febc46d9ce", "source", True),
267-
# ("test_connector_id", "destination", True),
266+
("f45dd701-d1f0-4e8e-97c4-2b89c40ac928", "source", True),
267+
# ("......-....-....-....-............", "destination", True),
268268
],
269269
)
270270
def test_check_connector(
@@ -286,25 +286,3 @@ def test_check_connector(
286286
pytest.fail("check_connector function is not implemented")
287287
except AirbyteError as e:
288288
pytest.fail(f"API call failed: {e}")
289-
290-
291-
def test_check_connector_integration(
292-
api_root,
293-
airbyte_cloud_client_id,
294-
airbyte_cloud_client_secret,
295-
) -> None:
296-
actor_id = "test_actor_id"
297-
connector_type = "source"
298-
try:
299-
result, error_message = check_connector(
300-
actor_id=actor_id,
301-
connector_type=connector_type,
302-
client_id=airbyte_cloud_client_id,
303-
client_secret=airbyte_cloud_client_secret,
304-
api_root=api_root,
305-
)
306-
assert result is not None
307-
except NotImplementedError:
308-
pytest.fail("check_connector function is not implemented")
309-
except AirbyteError as e:
310-
pytest.fail(f"API call failed: {e}")

0 commit comments

Comments
 (0)