Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat: add `composio.connected_accounts.wait_for_connection`

angrybayblade0e8c2f747694
diff --git a/python/composio/core/models/connected_accounts.py b/python/composio/core/models/connected_accounts.py
index 46edaf58e..e8439740a 100644
--- a/python/composio/core/models/connected_accounts.py
+++ b/python/composio/core/models/connected_accounts.py
@@ -4,6 +4,8 @@ import functools
import time
import typing as t
+import typing_extensions as te
+
from composio import exceptions
from composio.client import HttpClient
from composio.client.types import (
@@ -68,6 +70,15 @@ class ConnectionRequest(Resource):
message=f"Timeout while waiting for connection {self.id} to be active",
)
+ @classmethod
+ def from_id(cls, id: str, client: HttpClient) -> te.Self:
+ return cls(
+ id=id,
+ status=client.connected_accounts.retrieve(nanoid=id).status,
+ redirect_url=None,
+ client=client,
+ )
+
class AuthScheme:
"""
@@ -341,5 +352,19 @@ class ConnectedAccounts:
client=self._client,
)
+ def wait_for_connection(
+ self,
+ id: str,
+ timeout: t.Optional[float] = None,
+ ) -> connected_account_retrieve_response.ConnectedAccountRetrieveResponse:
+ """
+ Wait for connected account with given ID to be active
+ """
+ return ConnectionRequest.from_id(
+ id=id, client=self._client
+ ).wait_for_connection(
+ timeout=timeout,
+ )
+
auth_scheme = AuthScheme()