如果我运行以下脚本从 slack 发送消息,我会收到一个丢失的范围错误,到目前为止我无法解决!
import logging
logging.basicConfig(level=logging.DEBUG)
from slack import WebClient
from slack.errors import SlackApiError
slack_token = 'xoxb-xxxxxx-xxxxxxxx'
client = WebClient(token=slack_token)
try:
response = client.chat_postMessage(
channel="C018KGV8GHJ",
text="Hello from your app! :tada:"
)
except SlackApiError as e:
#You will get a SlackApiError if "ok" is False
assert e.response["error"] # str like 'invalid_auth', 'channel_not_found'
我收到以下错误:'ok': False, 'error': 'missing_scope', 'needed': 'chat:write:bot', 'provided': 'incoming-webhook'
脚本来自slack网页
如何解决 missing_scope 错误?
最佳答案
问题是我如何设置 slack API。我重新安装了 API:需要启用传入的 webhooks,在权限中:需要激活 Channel:Read 和 Chat:Write。还需要将 API 添加到 channel 中。之后一切正常!
关于python - 缺少来自 python 脚本的范围错误松弛消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63314630/