Imagine I have a Slack app. After someone logs in with his or her Slack account, I get their team ID.
Is it possible to use this team ID to get a list of all users that belong to the same team as the logged in one?
What I tried
I looked at the users.list request in the Slack docs, but it appears that it returns only those users who are in the same team as me (i. e. I can get a list of my colleagues, but not those of another user). In particular, there is no way to specify the team id.
Yes, that is possible. The Slack team is linked to the access token you use for users.list
. If you use your own access token, you will of course only get the users from your own team.
To get the users from other Slack teams you need to use the access token your Slack app received during installation to that team (e.g. via Slack button). Your Slack app will also need the OAuth permission scopes users:read
.