Slack API 不返回私人频道
Slack API not returning private channels
我正在尝试获取 Slack 中的私人频道列表(基于每个用户都可以),但我无法查看此信息。我最初将我的应用程序安装到 Slack 的工作区中,并获得了 xoxp-4...........
形式的 OAuth 令牌。
应用程序 OAuth 令牌
当我尝试使用 slack 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
方法默认仅 return public 个频道。要同时获得私人频道,您需要相应地设置参数 types
。例如types = public_channel,private_channel
.
类似于调用channels.list
. Channels.list
will only return public channels. If you want to get the private channels you need to call groups.list
。 (请注意,由于历史原因,私人频道在 API 中称为组)。
一般来说,我会推荐使用 conversations.list
,它更强大,也是获得所有类型对话的推荐方法。
我正在尝试获取 Slack 中的私人频道列表(基于每个用户都可以),但我无法查看此信息。我最初将我的应用程序安装到 Slack 的工作区中,并获得了 xoxp-4...........
形式的 OAuth 令牌。
应用程序 OAuth 令牌
当我尝试使用 slack 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
方法默认仅 return public 个频道。要同时获得私人频道,您需要相应地设置参数 types
。例如types = public_channel,private_channel
.
类似于调用channels.list
. Channels.list
will only return public channels. If you want to get the private channels you need to call groups.list
。 (请注意,由于历史原因,私人频道在 API 中称为组)。
一般来说,我会推荐使用 conversations.list
,它更强大,也是获得所有类型对话的推荐方法。