我如何限制Slack应用程序以仅在添加的私有频道中检索用户信息?
我有一个Slack应用程序,该应用程序正在请求权限用户:read,users.read.email。该应用程序将被添加到私人频道#xyz中。我不希望此应用程序从任何公共渠道检索信息,并仅限于扩展添加此应用程序的用户信息(此处#xyz)。 使用用户。阅读范围此应用程序可以调用用户。LISTAPI(Slack Team中的所有用户列出),并在我的工作区中获取用户的信息。
如何处理它以限制添加的专用渠道的响应?
I have a slack app which is requesting a permission users:read , users.read.email. This app will be added to a private channel say #xyz. I do not want this app to retrieve information from any public channel and be limited to extact the user info where this app is added(#xyz here).
With users.read scope this app can call users.list api (list all users in a Slack team) and get the info of users in my workspace.
How can I handle this to limit the response from the private channel where it is added?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,在调用
users.list
方法时,无法防止从公共渠道出现数据。也很难基于通道ID过滤数据,因为此方法不会返回通道数据。您需要调用对话。list
并过滤所有私人频道。使用机器人令牌时,您只会看到机器人是其成员的频道的私人频道数据。检查is_private:true
标志以确定频道是否是私有的。然后,对于每个私有频道,您可以调用
对话。会员
方法以获取该频道中所有用户的用户ID列表。然后,您需要在返回的每个用户ID上调用users.info
。这不是最优雅的方法,但我想不出一种简单的方式。
Unfortunately, there is no way to prevent data from public channels to appear when calling the
users.list
method. It would also be difficult to filter data based on channel id because this method does not return channel data. You would need to make a call toconversations.list
and filter out all private channels. When using your bot token, you will only see private channel data for channels that your bot is a member of. Check for theis_private:true
flag to determine whether a channel is private.Then for each private channel you could then call the
conversations.members
method to get a list of user ids for all the users in that channel. You'd then need to callusers.info
on each user id that's returned.Not the most elegant way to go about it but I can't think of an easier way I'm afraid.