https://linen.dev logo
Unexpected Redirection to Stack Exchange During OA...
# 🖥│support-forum
b
Hey @udaysidagana , I’m trying to initiate a connection to Miro. I’ve already created the auth_config and tested the integration locally, and it works perfectly fine. However, when I attempt the same on the staging environment, I’m running into a strange issue. Below is the payload I’m using:
Copy code
[initiateComposioConnection] payload {
  app: { uniqueKey: 'miro_tars', integrationId: '' },
  config: { name: 'miro_tars', useComposioAuth: true, authSchema: 'OAUTH2' },
  connection: {
    initiateData: {},
    entityId: '__Uc4d4dz',
    extra: {
      redirectURL: 'https://[my_app.com]/api/oauth?referer=/tools/oauth/failure&redirectTo=/tools/oauth/success?tool_id=688770238fbdb148ca534782'
    }
  }
}
Breaking down the whole log into sub messages,...
The strange part is that when the integrationId is left empty, the connection is incorrectly being routed to another integration—Stack Exchange. This issue isn't limited to Miro; any tool I try to connect without explicitly setting the integrationId ends up being redirected to Stack Exchange’s OAuth instead of their intended integration. Here’s a log from the connection instance response that shows this unexpected behavior:
Copy code
2025-07-28T12:42:20: composioConnectedAccId 7693d25e-db1c-4637-a746-787793d10ade
2025-07-28T12:42:20: connectionData {
  id: '7693d25e-db1c-4637-a746-787793d10ade',
  integrationId: 'f657cba3-e483-4c3c-9b5a-4c571e7a9db0',
  clientUniqueUserId: '__Uc4d4dz',
  status: 'ACTIVE',
Copy code
data: {
    status: 'ACTIVE',
    access_token: '[REDACTED_TOKEN]',
    code_verifier: '[REDACTED_CODE_VERIFIER]',
    redirectUrl: 'https://[REDACTED_DOMAIN]/api/oauth?referer=/tools/oauth/failure&redirectTo=/tools/oauth/success?tool_id=688770238fbdb148ca534782',
    callback_url: 'https://backend.composio.dev/api/v1/auth-apps/add',
    finalRedirectUri: 'https://[REDACTED_DOMAIN]/api/oauth?referer=/tools/oauth/failure&redirectTo=/tools/oauth/success?tool_id=688770238fbdb148ca534782',
    bearer_token: '[REDACTED_TOKEN]',
    full: 'https://api.stackexchange.com',
    base_url: 'https://api.stackexchange.com',
    headers: {
      'x-request-id': '[REDACTED_REQUEST_ID]',
      Authorization: 'Bearer [REDACTED_TOKEN]'
    },
    queryParams: {},
    extra_data: {}
  },
  deleted: false,
  enabled: true,
  appUniqueId: 'stack_exchange',
  authConfig: {
    id: 'ac_N56I8-bAuY7D',
    auth_scheme: 'OAUTH2',
    is_composio_managed: true,
    is_disabled: false,
    deprecated: { uuid: 'f657cba3-e483-4c3c-9b5a-4c571e7a9db0' }
  },
  isDisabled: false,
  connectionParams: {
    status: 'ACTIVE',
    access_token: '[REDACTED_TOKEN]',
    code_verifier: '[REDACTED_CODE_VERIFIER]',
    redirectUrl: 'https://[REDACTED_DOMAIN]/api/oauth?referer=/tools/oauth/failure&redirectTo=/tools/oauth/success?tool_id=688770238fbdb148ca534782',
    callback_url: 'https://backend.composio.dev/api/v1/auth-apps/add',
    finalRedirectUri: 'https://[REDACTED_DOMAIN]/api/oauth?referer=/tools/oauth/failure&redirectTo=/tools/oauth/success?tool_id=688770238fbdb148ca534782',
    bearer_token: '[REDACTED_TOKEN]',
    full: 'https://api.stackexchange.com',
    base_url: 'https://api.stackexchange.com',
    headers: {
      'x-request-id': '[REDACTED_REQUEST_ID]',
      Authorization: 'Bearer [REDACTED_TOKEN]'
    },
    queryParams: {},
    extra_data: {}
  },
  appName: 'stack_exchange',
  logo: '',
  labels: {}
}
Let me know if I’m missing something in the payload or configuration. Ideally, even without explicitly passing the integrationId, it shouldn’t default to a completely unrelated tool like Stack Exchange.
c
Hi Naik, could you please provide some context for the “staging”?
b
Copy code
[initiateComposioConnection] payload {
  app: { uniqueKey: 'miro_tars', integrationId: '' },
  config: { name: 'miro_tars', useComposioAuth: true, authSchema: 'OAUTH2' },
  connection: {
    initiateData: {},
    entityId: '__Uc4d4dz',
    extra: {
      redirectURL: 'https://[my_app.com]/api/oauth?referer=/tools/oauth/failure&redirectTo=/tools/oauth/success?tool_id=688770238fbdb148ca534782'
    }
  }
}
This is what the payload is being sent to initiate the composio tool connection
You could see that the integrationId is empty and the redirect URL and entity Id are specific to the user
when the integratino Id is empty we should have an error message indicating the issue of missing required parameters. Instead the connection is being established to stack_exchage. https://discord.com/channels/1170785031560646836/1399424539057979514/1399424813550014614
You can see the connected account Id and the integration Id that
Copy code
async function initiateComposioConnection({ toolName, accountId, returnTo }) {
  try {
    const payload = {
      app: {
        uniqueKey: `${toolName}_tars`,
        integrationId: integration_id_here
      },
      config: {
        name: `${toolName}_tars`,
        useComposioAuth: conditional_value_here,
        authSchema: "OAUTH2",
      },
      connection: {
        initiateData: {},
        entityId: accountId,
        extra: {
          redirectURL: returnTo,
        }
      }
    };
    console.log('[initiateComposioConnection] payload', payload);

    const response = await axios.post(
      `${BASE_URL}/v2/connectedAccounts/initiateConnection`,
      payload,
      {
        headers: {
          "x-api-key": api_key,
          "Content-Type": "application/json"
        }
      }
    );
    const initiateConnectionResponse = response.data;
    return {
      url: initiateConnectionResponse?.connectionResponse?.redirectUrl,
      composio_connected_acc_id: initiateConnectionResponse?.connectionResponse?.connectedAccountId
    };
  } catch (error) {
    console.error('[initiateComposioConnection] Error:', error);
    throw new Error(`Error generating authorization URL: ${error.message}`);
  }
}
This is the sample connection-establishing code snippet we us.
c
Hi, It looks like you still missed to provide the context regarding "staging" and working fine before it. This info will help us in debugging.
b
I tested the integration locally and we use a seperate server to test the integration before pushing to production. For some reason the integration Id is missing and that is fine. But, when the integration id is empty , how come the connection got established to stack_exchange ( there auth config created on my account). This should ideally return us an error or some other information regarding the missing required params.
c
Thanks for the information, We will look into this.
We couldn't reproduce the Issue, Could you share reproducible code snippet(connectedAccount.initiate)? Also, please specify the SDK version along with Imports. Thanks!
b
Copy code
const response = await axios.post(
      `${BASE_URL}/v2/connectedAccounts/initiateConnection`,
      payload,
      {
        headers: {
          "x-api-key": api_key,
          "Content-Type": "application/json"
        }
      }
    );
We are using this endpoint to establish the connection
c
Could you try using this endpoint: and lmk if it works for you? I've checked your code base, Ideally it should return a redirectUrl to the specified
appName
, in case if appName is omitted and IntegrationId is passed empty, it should throw and error. Also, we recommend migrating to V3, is there any specific use case or feature for choosing v1/v2 for your production?
b
We’re currently using v2 in production since we integrated before v3 was released, so we’ve continued with that version for consistency. Let us know if there are any critical differences or migration blockers we should be aware of.
c
Version 3 is comparatively stable with added features. You can refer to our [documentation](https://docs.composio.dev/docs/welcome) to check if there are any blockers from v1/v2.