Sack API未返回私有频道

编程入门 行业动态 更新时间:2024-10-25 13:21:09
本文介绍了Sack API未返回私有频道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试获取Slack中的私人频道列表(每个用户都可以),但我在查看此信息时遇到了困难。我最初将我的应用程序安装到Slack的工作区中,得到了xoxp-4...........形式的OAuth令牌。

App OAuth令牌

当我尝试使用Sack API(节点SDK)时,我只能得到公开列出的频道。

await new WebClient(`xoxp-4.....`) .conversations .list({ exclude_archived: true }) ).channels

如果我尝试使用Slack API测试器抓取channel list,得到的结果相同。

用户OAuth令牌 我已经按照OAuth 2.0流程获取了给定用户(我自己)的令牌。我认为我做得很正确(以下是我的回复):

{ ok: true, access_token: 'xoxp-4.........', scope: 'identify,bot,commands,channels:history,groups:history,im:history,mpim:history,channels:read,emoji:read,groups:read,im:read,search:read,team:read,users:read,users:read.email,usergroups:read,users.profile:read,chat:write:user,chat:write:bot,links:read', user_id: 'UD......', team_name: '............', team_id: '.......', scopes: ['identify', 'bot', 'commands', 'channels:history', 'groups:history', 'im:history', 'mpim:history', 'channels:read', 'emoji:read', 'groups:read', 'im:read', 'search:read', 'team:read', 'users:read', 'users:read.email', 'usergroups:read', 'users.profile:read', 'chat:write:user', 'chat:write:bot', 'links:read' ] }

有趣的是,我发现这为我提供了完全相同的OAuth令牌,如果我转到应用程序管理(我假设是因为是我将应用程序安装到工作区)。

显然,因为它是相同的令牌,所以我仍然没有权限查看私有频道,尽管据我所知,我应该能够作为用户做我能做的一切?

有人能告诉我我可能遗漏了什么吗?

推荐答案

您没有获得专用频道的原因是您没有请求它们。

conversations.list方法默认只返回公共频道。要获得私有频道,您需要相应地设置参数types。例如types = public_channel,private_channel。

类似于调用channels.list。Channels.list将仅返回公共频道。如果您想获取私密频道,您需要拨打groups.list。(请注意,由于历史原因,私有频道在API中称为组)。

总的来说,我建议使用conversations.list,这是更强大的方法,也是获取所有类型对话的推荐方法。

更多推荐

Sack API未返回私有频道

本文发布于:2023-10-28 23:42:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538105.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:频道   Sack   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!