我正在使用passport-slack向Slack进行身份验证,但我总是在缺少作用域的问题上出错。
在passport的作用域中,我已经请求了identity.basic权限,但我一直从Slack API得到以下错误。
我做错了什么?
passport.use('Slack', new SlackStrategy({
clientID : secret.slack.id,
clientSecret : secret.slack.secret,
skipUserProfile : false,
callbackURL : '/sessions/slack/callback',
// scope : ['channels:read', 'chat:write:bot', 'identity.basic'],
scope : ['identity.basic', 'identity.email', 'identity.avatar', 'identity.team', 'channels:read', 'chat:write:bot'],
passReqToCallback: true
}, (req, accessToken, scopes, profile, done) => {
// Code to process the response
})
){
"ok":false,
"error":"missing_scope",
"needed":"identity.basic",
"provided":"identify,incoming-webhook,channels:read,chat:write:bot"
}发布于 2019-09-02 18:47:13
已解决-
我使用Slack在频道上发布消息。这些权限所需的作用域为-
channels:read, chat:write:bot
出于上述目的,我们应该使用add to slack按钮,该按钮提供了工作区的令牌以在通道上发布,从而完全消除了对SlackStrategy的需要。
最初,我使用的SlackStrategy是不正确的,因为它只用于Login with Slack,这是我不需要的。
因此,我现在删除了SlackStrategy,因为我所需要的只是在Slack上发布的许可,而不是通过Slack对用户进行身份验证。
发布于 2019-09-01 20:30:45
您的passport使用中有一个拼写错误,请尝试并删除方法的第一个参数,例如:
passport.use(new SlackStrategy({
clientID : secret.slack.id,
clientSecret : secret.slack.secret,
skipUserProfile : false,
callbackURL : '/sessions/slack/callback',
// scope : ['channels:read', 'chat:write:bot', 'identity.basic'],
scope : ['identity.basic', 'identity.email', 'identity.avatar', 'identity.team', 'channels:read', 'chat:write:bot'],
passReqToCallback: true
}, (req, accessToken, scopes, profile, done) => {
// Code to process the response
})
)点击这里查看工作示例:https://github.com/mjpearson/passport-slack#configure-strategy
https://stackoverflow.com/questions/57745971
复制相似问题