#how can I initiate connection

1 messages · Page 1 of 1 (latest)

bronze badge
#

how can I initiate a new connection in composio? i want to use gmail

still dockBOT
#

To initiate a new connection to Gmail in Composio, follow these steps:

  1. Create an Auth Config
    First, you need an authentication config for Gmail. You can do this via the Composio dashboard or programmatically.

    • On the dashboard: Go to Gmail in the Composio marketplace, configure the auth settings, and create the config. Copy the generated auth_config_id (starts with ac_)—you’ll need this for the next step.
    • Programmatically (Python example):
    from composio import Composio
    
    # Replace with your actual values
    gmail_auth_config_id = "ac_YOUR_GMAIL_CONFIG_ID"
    user_id = "0000-0000-0000"  # Your user UUID
    
    composio = Composio()
    
    def authenticate_toolkit(user_id: str, auth_config_id: str):
        connection_request = composio.connected_accounts.initiate(
            user_id=user_id,
            auth_config_id=auth_config_id,
        )
        print(f"Visit this URL to authenticate Gmail: {connection_request.redirect_url}")
        # Wait for the auth flow to complete
        connection_request.wait_for_connection(timeout=15)
        return connection_request.id
    
    connection_id = authenticate_toolkit(user_id, gmail_auth_config_id)
    # Optionally, verify the connection:
    connected_account = composio.connected_accounts.get(connection_id)
    print(f"Connected account: {connected_account}")
    

    This will print a URL for the user to complete the OAuth flow. After authentication, the connection is established and ready to use Connecting to Gmail.

#
  1. Alternative: Using REST API or Frameworks
    If you’re using a REST API or frameworks like FastAPI or Hono, you can expose an endpoint that calls the connection initiation logic. The endpoint should return the redirect_url for the user to complete authentication Testing the API with curl.

Summary:

  • Create an auth config for Gmail (dashboard or code).
  • Use the connected_accounts.initiate method with your user_id and auth_config_id.
  • Direct the user to the returned redirect_url to complete authentication.

Let me know if you need a code sample for a specific language or framework!

bronze badge
#

i want the TS sdk snipprt