Slack API不返回私有通道
我正在尝试获取Slack中的私有频道列表(在每个用户的基础上很好),但我很难看到这些信息。我最初将我的应用程序安装到Slack的工作区中,并以xoxp-4...........
的形式获得了一个OAuth令牌。
App OAuth令牌
当我尝试使用松弛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
,它更强大,是推荐的方法来获得所有类型的对话。