SLACK BOLT PYTHON -虽然应用程序应该安装到这个工作区,但没有找到它的AuthorizeResult(从



我想建立一个简单的Slack螺栓python项目,所以我遵循这个文档。但是当我使用python_dotenv,然后运行我的主文件(app.py),我遇到这个错误:

As `installation_store` or `authorize` has been used, `token` (or SLACK_BOT_TOKEN env variable) will be ignored.
Although the app should be installed into this workspace, the AuthorizeResult (returned value from authorize) for it was not found.

注意:通过删除主文件(app.py)中的这一行:

load_dotenv ()

并使用导出方法定义令牌,一切正常。

这是我的主文件:

import os
from dotenv import load_dotenv
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
import logging
load_dotenv() # by deleting this file, the error will be gone, but I want using the dotenv pip

app = App(token=os.environ.get("SLACK_BOT_TOKEN"))
logger = logging.getLogger(__name__)
@app.message("hello")
def message_hello(message, say):
# say() sends a message to the channel where the event was triggered
say(f"Hey there <@{message['user']}>!")

# Start your app
if __name__ == "__main__":
SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start()

我不知道为什么,但是我在。env文件中删除了额外的键,一切都很好。

在.env文件中::

SLACK_APP_TOKEN=xapp-fake-token
SLACK_BOT_TOKEN=xoxb-fake-token
USER_TOKEN=xoxp-fake-token
SLACK_CLIENT_ID=aa.bb
SLACK_CLIENT_SECRET=YOUR_CLIENT_SECRET
SLACK_API_TOKEN_APP_LEGACY=xoxb-fake-token
SLACK_SIGNING_SECRET=YOUT_SIGNING_SECRET

:

SLACK_APP_TOKEN=xapp-fake-token
SLACK_BOT_TOKEN=xoxb-fake-token

最新更新