【发布时间】:2019-07-11 21:52:16
【问题描述】:
我正在尝试获取 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 令牌(我假设是因为是我将应用程序安装到工作区)。
显然,因为它是同一个令牌,我仍然没有权限查看私人频道,即使据我所知,我应该能够做我作为用户可以做的所有事情?
谁能指出我可能缺少的东西?
【问题讨论】:
-
我遇到了类似的问题,我找不到确切解决方案的链接。我认为这与必须使用遗留令牌来获得访问权限有关。 api.slack.com/custom-integrations/legacy-tokens 我使用的是 python 而不是 node,这是去年,所以事情可能已经改变了。
-
@Emile 我刚刚从 legacy-tokens 页面尝试了一个令牌,不幸的是,使用
channels.listapi 函数它似乎没有任何不同。 -
我刚才也意识到我是从桌面下载的,所以和你的情况不太一样。
标签: javascript node.js slack slack-api