Arun
Arun

Reputation: 2003

Slack conversations.list method does not list all the channels

I have a slack application and I have authenticated using this application. When I list all the channels, some of the private channels are not listed. Do we need the access token of workspace admin to list all the private and public channels?

Upvotes: 9

Views: 8589

Answers (3)

Kisu Yang
Kisu Yang

Reputation: 71

response = client.conversations_list(types="public_channel, private_channel")

See https://slack.dev/python-slackclient/conversations.html

Upvotes: 7

Dr-Bracket
Dr-Bracket

Reputation: 5574

Stumbled across this question when Googling for a similar issue in a large org - I was getting the public channels, but not all of them were showing.

Turns out Slack has a default limit of returning 100 channels. To bypass this, simply pass a limit: 9999 parameter, eg:

  app.client.conversations.list({
    token: process.env.SLACK_BOT_TOKEN,
    limit: 9999
  }).then((res: any) => {...})

See also: conversations.list API

Upvotes: 14

Erik Kalkoken
Erik Kalkoken

Reputation: 32852

Here is how Slack's security architecture works, which explains why you don't get all private channels with conversations.list.

A user only can only see private channel he is a member of. That includes users with admins and owner role, so even the creator of a workspace does not see private channels he is not invited to.

There are two types of tokens:

  • User token inherit the access rights from the user who installs the Slack app. So if you installed a Slack app it can only see the private channels that you are a member of.
  • Its a bit different with bot token. With a bot token the app can only see private channel the bot user is a member of.

There are two workarounds to get access to all channels:

Generic user

Ensure a the generic user (e.g. slackadmin) is a member of all private channels. Then using his access token a Slack app also has access to all those private channels. This is an organizational solution.

Collect all user tokens

Collect the tokens of all users on your workspace and then use those tokens to access all conversations incl. private channels their are a member of. This can be achieved by asking every user to install your Slack app once (via standard OAuth "Add to Slack" process), which is called a configuration in Slack terms.

Upvotes: 4

Related Questions