Skip to content

Commit

Permalink
fix: fetch default auth scheme from API during initiate_connection (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tushar-composio authored Nov 23, 2024
1 parent 624accf commit 31f363d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ def fetch_expected_integration_params(
continue
return [f for f in scheme.fields if not f.expected_from_customer]
raise ComposioSDKError(
message=f"{app} does not support {auth_scheme} auth scheme"
message=f"{app.name!r} does not support {auth_scheme!r} auth scheme"
)

def create_integration(
Expand Down Expand Up @@ -1384,7 +1384,7 @@ def initiate_connection(
redirect_url: t.Optional[str] = None,
connected_account_params: t.Optional[t.Dict] = None,
*,
auth_scheme: AuthSchemeType = "OAUTH2",
auth_scheme: t.Optional[AuthSchemeType] = None,
auth_config: t.Optional[t.Dict[str, t.Any]] = None,
) -> ConnectionRequestModel:
"""
Expand All @@ -1398,19 +1398,18 @@ def initiate_connection(
:param auth_scheme: (Optional[AuthSchemeType]): Authentication scheme to use
:return: (ConnectionRequestModel) Details of the connection request.
"""

if auth_scheme not in AUTH_SCHEMES:
if auth_scheme is not None and auth_scheme not in AUTH_SCHEMES:
raise ComposioSDKError(f"'auth_scheme' must be one of {AUTH_SCHEMES}")

if auth_scheme is not None:
if auth_scheme not in AUTH_SCHEMES:
raise ComposioSDKError(f"'auth_scheme' must be one of {AUTH_SCHEMES}")

if integration_id is None:
if app is None:
raise ComposioSDKError(
message="Both `integration_id` and `app` cannot be None"
)

if auth_scheme is None:
auth_scheme = self.get_auth_scheme_for_app(app).auth_mode

try:
integration_id = self._get_integration_for_app(
app=t.cast(
Expand Down

0 comments on commit 31f363d

Please sign in to comment.