https://linen.dev logo
Slack Tools fail with custom auth config after suc...
# 🖥│support-forum
p
I have a custom slack auth config with a Slack app I created. After a user completes the connection to slack using this custom auth config, I see the active account in the Composio platform. Then, when I try to execute different Slack tools, it always fails. I tried using Composio's playground in the platform, but the tool execution also gets stuck with infinite loading. here is an example callback: { "error": "SLACK_LIST_CHANNELS failed", "connection_id": "ca_TgezOEJp-ja1", "tool_error": "Error executing tool SLACK_LIST_CHANNELS", "raw_connection_data": { "id": "ca_TgezOEJp-ja1", "appName": "slack", "status": "ACTIVE", "metadata": { } } } What can I do to execute the Slack tools successfully after the account is active? thanks!
c
Hey there đź‘‹, Could you the logId of the failed Tool call? It will help us in debugging!
p
Thanks! I don't see any logs in the auth config logs.. this is the auth_config id: ac_At7OkIMgrtGX.. is that helpful?
c
Got it. Can you explain how you tried to make a Tool call, other than using the Playground, if you attempted it differently?
p
yes, this is my tool call: const result = await composio.tools.execute( "SLACK_LIST_CHANNELS", { arguments: { as_user: true, }, }, { connectedAccountId: activeConnection.id, } )
c
SLACK_LIST_ALL_CHANNELS
does not take
as_user
as param, you can refer to this documentation to understand the Tool schema:
p
Thank you. I now tried to execute this tool: const result = await composio.tools.execute( "SLACK_LIST_ALL_CHANNELS", { limit: 1000, // Get up to 1000 channels exclude_archived: false, // Include archived channels types: "public_channel,private_channel,mpim,im" // All conversation types }, { connectedAccountId: activeConnection.id, } ) I received this callback: { "error": "SLACK_LIST_ALL_CHANNELS failed", "connection_id": "ca_kD84MAi_yhIz", "tool_error": "400 {\"error\":{\"message\":\"Validation error while processing request\",\"error_code\":10400,\"suggested_fix\":\"Please check the payload.\",\"errors\":[\"Error in payload.text.arguments: Only one of 'text' or 'arguments' must be provided\"]}}", "raw_connection_data": { "id": "ca_kD84MAi_yhIz", "integrationId": "ca_kD84MAi_yhIz", "connectedAccountId": "ca_kD84MAi_yhIz", "appName": "slack", "appUniqueId": "ca_kD84MAi_yhIz", "status": "ACTIVE", "metadata": { "workspace_id": "ca_kD84MAi_yhIz" } } } I still don't see anything in the Composio logs dashboard.
c
You can use the following snippet to list all Slack channels (both public and private) using the Composio SDK:
Copy code
ts
import { Composio } from "@composio/core";

const composio = new Composio();

const res = await composio.tools.execute("SLACK_LIST_ALL_CHANNELS", {
  userId: "default",
  arguments: {
    limit: 1000,
    types: "public_channel,private_channel",
    exclude_archived: false,
  },
});

console.log(res);
Notes: - You have to add extra scopes to use extra types.
p
Unfortunately I'm still getting this error: { "error": "SLACK_LIST_ALL_CHANNELS failed", "connection_id": "ca_kD84MAi_yhIz", "tool_error": "400 {\"error\":{\"message\":\"Validation error while processing request\",\"error_code\":10400,\"suggested_fix\":\"Please check the payload.\",\"errors\":[\"Error in payload.text.arguments: Only one of 'text' or 'arguments' must be provided\"]}}", "raw_connection_data": { "id": "ca_kD84MAi_yhIz", "integrationId": "ca_kD84MAi_yhIz", "connectedAccountId": "ca_kD84MAi_yhIz", "appName": "slack", "appUniqueId": "ca_kD84MAi_yhIz", "status": "ACTIVE", "metadata": { "workspace_id": "ca_kD84MAi_yhIz" } } }
c
Just to confirm, you are getting the error even with the snippet I shared? Could you please specify the SDK version you are currently using?
p
yes, very similar snippet: const result = await composio.tools.execute("SLACK_LIST_ALL_CHANNELS", { userId: user.id, arguments: { limit: 1000, exclude_archived: false, types: "public_channel,private_channel", }, }) I am using SDK version @composio/core: ^0.1.39 and receiving this error: { "error": "SLACK_LIST_ALL_CHANNELS failed", "connection_id": "ca_kD84MAi_yhIz", "tool_error": "422 {\"error\":{\"message\":\"Slack oauth2 auth not in correct state\",\"code\":1700,\"status\":422,\"request_id\":\"d58de636-d508-469a-908d-03d78deb5ea0\",\"suggested_fix\":\"\"}}", "raw_connection_data": { "id": "ca_kD84MAi_yhIz", "integrationId": "ca_kD84MAi_yhIz", "connectedAccountId": "ca_kD84MAi_yhIz", "appName": "slack", "appUniqueId": "ca_kD84MAi_yhIz", "status": "ACTIVE", "metadata": { "workspace_id": "ca_kD84MAi_yhIz" } } }
c
I can see a different error message with this snippet. Also, Could you provide some context on why the Integration Id is mapped to connected account Id? Similarly, the appUniqueId and workspaceId? Could you share a code snippet or reproducible steps on how you created an Auth Config and initiated a connection?
p
Thanks! I updated the parameter mapping and now geeting this error: { "error": "SLACK_LIST_ALL_CHANNELS failed", "connection_id": "ca_kD84MAi_yhIz", "tool_error": "422 {\"error\":{\"message\":\"Slack oauth2 auth not in correct state\",\"code\":1700,\"status\":422,\"request_id\":\"b0c067b9-0eae-4482-9398-8307b36749c9\",\"suggested_fix\":\"\"}}", "raw_connection_data": { "id": "ca_kD84MAi_yhIz", "appName": "slack", "status": "ACTIVE", "metadata": { } }
Connection initiation code (all methods): 1. API Endpoint for Connection Initiation // src/app/api/mcp/slack/connect/route.ts export async function POST(_request: NextRequest) { try { const supabase = await createClient() const { data: { user } } = await supabase.auth.getUser() if (!user) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) } const slackService = SlackMCPService.getInstance(user.id) const result = await slackService.initializeConnection() return NextResponse.json(result) } catch (_error) { return NextResponse.json({ error: "Failed to initialize Slack connection" }, { status: 500 }) } } 2. Connection Initiation Method // src/lib/composio/slack-service.ts:48-68 async initializeConnection(): Promise { try { const params = { userId: this.userId || "default", authConfigId: process.env.COMPOSIO_SLACK_AUTH_CONFIG_ID!, } const connection = await composio.connectedAccounts.initiate( params.userId, params.authConfigId ) const result = { authUrl: connection.redirectUrl || "", connectionId: connection.id || "", } return result } catch (_error) { throw new Error("Failed to initialize Slack connection") } }
3. OAuth Callback Handler // src/app/oauth/composio/route.ts:84 export async function GET(request: NextRequest) { try { const searchParams = request.nextUrl.searchParams const code = searchParams.get("code") if (code) { return await handleSuccessfulOAuth() } return createErrorRedirect("invalid_callback") } catch (_error) { return createErrorRedirect("callback_failed") } } async function handleSuccessfulOAuth(): Promise { const supabase = await createClient() const { data: { user } } = await supabase.auth.getUser() const slackService = SlackMCPService.getInstance(user.id) const connections = await slackService.getConnections() const initiatedConnection = connections.find((conn) => conn.status === "INITIATED") if (!initiatedConnection) { return createErrorRedirect("connection_not_found") } // Enable the connection - this makes it ACTIVE const enabled = await slackService.enableConnection(initiatedConnection.id) if (!enabled) { return createErrorRedirect("enable_failed") } // Save workspace info to database... return NextResponse.redirect(new URL("/knowledge?tab=my-tools&success=true", getBaseUrl())) } 4. Connection Enable Method // src/lib/composio/slack-service.ts:107-115 async enableConnection(connectionId: string): Promise { try { await composio.connectedAccounts.enable(connectionId) return true } catch (_error) { return false } }
@udaysidagana - do you need any other input from me to look into it?
c
Hi, Just to confirm— your auth config is created via Dashboard and White Labelling is done on your server? FYI: you don't need to add Access token, it will be inserted automatically.
p
Yes 👍
c
Hi, It seems like your connection logic is incorrect. You are trying to force enable the connection when in Initiated State, which makes it ACTIVE but has no metadata or tokens. You have to complete the Auth Flow in order to use the connection manually. Try going to the redirectUrl and finish the Auth Flow. Let me know if it works for you.
p
Hey @udaysidagana.. I tested your demo chat solution (https://chat.composio.dev/chat/47c6bb66-879a-4f4c-8983-c648ea4657f9) which uses your auth config with the composio app. Even there the Slack connection doesn't work. I decided to drop the Slack connection and start with your composio app and not custome auth config. now it works for me when connecting Notion. I think that you might have bugs with the Slack connection or the custome auth config.
c
I just checked it and Slack Custom Auth seems to be working fine. I didn't quite understand using composio auth config, are you trying to use composio's auth config and trying to connect your account to it? Also, your logic of enabling the INITIATED state should not Ideally work. Let me know if you made any changes to the code. Thanks!
p
Thank you, @udaysidagana .. I fixed the code and am not forcing initiated state to become enabled without the user permission.. what I mean using the composio auth config is using the Composio app in the Oauth flow (see attached screenshot). this can only work as a temp solution. https://cdn.discordapp.com/attachments/1401989563362312413/1404501263722348636/Screenshot_2025-08-11_at_17.23.38.png?ex=689b6b3b&is=689a19bb&hm=897c3499d38aa1157c0ca1fdc27ad58f666de1b793295cb5471bfe68d364f269&
c
Could you explain "this can work as a temp solution"? Also, the error "Slack oauth2 auth not in correct state" should be gone with the update you made, let me know if you are still facing any Issues with it.
2 Views