title: Get a list of all private channels with Slack API
body: <p>I've been trying to get a list of all "groups" in my Slack team. However, even with admin privs, <code>groups.list</code> only provides the groups that the token owner's account belongs to.</p>
  
  <p>The closest solution I've seen in my research involves getting a bot to sit in the channel. The bot's membership allows it to report on the channel, but then there's the logistical problem of getting the bot into every private channel, despite the fact that we can't list them programmatically.</p>
  
  <p>The code I've used to dig up private channel listings:</p>
  
  <pre><code>import requests
  import json
  
  token = '...'
  
  r = requests.post('https://slack.com/api/groups.list', data={'token': token, 'exclude_archived': 1})
  if r.ok:
    privatechannels = { c['id']: c['name'] for c in json.loads(r.text)['groups'] }
    print(privatechannels)
  </code></pre>