Sack API未返回私有频道 [英] Slack API not returning private channels

查看:22
本文介绍了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.listChannels.list将仅返回公共频道。如果您想获取私密频道,您需要拨打groups.list。(请注意,由于历史原因,私有频道在API中称为组)。

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

这篇关于Sack API未返回私有频道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆