#How do I disconnect an account from a specific integration?

1 messages · Page 1 of 1 (latest)

normal whale
ashen citrusBOT
#

Hey, you only need to pass the connectedAccountId to delete the connection for that specific user, don't need to pass the Integration ID.

IntegrationId is required when you call the initiate connection because info (like Auth method, Auth credentials, scopes) is configured at the integration level.

normal whale
#

Let's say we allow users to connect to 20 different services that have tools (Gmail, Slack, ClickUp, Harvest, etc.). We have a user that has connected to five services, but now wants to disconnect from one of those five services, how do they do that?

ashen citrusBOT
normal whale
#

Yes, but how does the delete-connection Composio API know which integration the user wants diconnected? Isn't the same account ID used for all the different connections for the same user?

gentle glacier
#

hey!
when you're deleting a connection, you specify the connection ID. that particular connection ID is mapped to the user and the integration.

so if you wanna delete the connection for user "default" which is mapped to "GMAIL 2", then you can do something like this:

import { OpenAIToolSet } from "composio-core";

const toolset = new OpenAIToolSet();

const entity = await toolset.getEntity("default");
const connections = await entity.getConnections();

for (const connection of connections) {
  console.log(connection.appName);
  console.log(connection.integrationId);
  if (connection.integrationId == "aa80ca4e-6e47-451f-bd3f-7827d58d6f31") {  // integration for gmail 2
    console.log("Deleting connection", connection.id);
    const res = await toolset.connectedAccounts.delete({
      connectedAccountId: connection.id,
    });
    console.log(res);
  }
}
normal whale
#

To be clear, are you saying that if one of our customers wants to delete one of his multiple connections (for example, our customer who has account ID 1234-567-8888 has 5 connections and wants to delete just one of those), then we need to loop all the customer connections, and when we find the integration ID for that service that user wants to disconnect, then we need to issue a disconnect for that specific account id? Is there not a more efficient way to do this?

ashen citrusBOT
#

In most cases, you ideally would only allow one connected account per app but if you are allowing multiple connectedAccounts for an app for the same user, you will need to handle this.

charred whale
#

hey team, want to change my it's the account. used personal gmail for testing. want to switch to professional. Not sure how to do it?