Connected Accounts
Guide to creating connections for multiple users
Introduction to Connected Accounts
- When a user connects their account, a
connected_account
object is created. - Connected Account securely stores authentication data such as api keys, access tokens and refresh tokens.
Introduction to Entities
- Each unique user/tenant is represented by a unique entity id.
- If you have two users, Jessica and Melissa, they will each have unique entity ids.
Connecting an Account for your User
Connecting a user account requires a few API calls to authenticate and authorize access. The process involves:
- Fetching Parameters to create a Connection - Get the authentication requirements for the chosen application (API Key, Subdomain URL, Username etc.)
- Collecting those parameters from the user - Gather the required parameters from your user interface
- Creating a Connection - Initialize a new connection with the collected parameters
- Handling OAuth Flow - For OAuth applications, redirect the user to complete authorization
- Verifying Connection Status - Check that the connection was successful
Code Snippets for Connecting an Account
Collect Parameters Required to create a Connection
To create a connected account for your user:
- Fetch required auth parameters for the application
- Collect these parameters from the user
- Initiate a new connection request
api_key
, Shopify: Requires shop_name
for OAuth flow Collect the required parameters from your user through your preferred interface (UI, chat, or API).
All parameters should be provided as strings.
Try creating a connection with the parameters collected
In the code snippets below replace redirect_url
Some applications require user redirection to complete the authentication process. Gmail for example requires redirecting the user to Google’s login page.
How to get all Connected Accounts?
Fetch the Connection Params (Status, Access Token, Refresh Token...)
If you want to use connection params locally and build custom actions -
Connection status can be failed
, initiated
or active
.
Example of how connection params would look like
You can fetch connection details after user is redirected back to your app. (If redirect was needed)
connection_status
& connectedAccountId
will be available in the query params.
Receiving Webhooks alerts on new Connections
Composio provides real-time webhook notifications for new connections. To utilize this feature:
- Set up webhook alerts in the Composio dashboard
- Configure your application to receive and parse the webhook payloads
This allows you to instantly track when users integrate new services with your application.
Was this page helpful?