-
Notifications
You must be signed in to change notification settings - Fork 263
/
Copy pathoauth_app.py
47 lines (29 loc) · 994 Bytes
/
oauth_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from slack_bolt import App
from slack_bolt.adapter.fastapi import SlackRequestHandler
app = App()
app_handler = SlackRequestHandler(app)
@app.event("app_mention")
def handle_app_mentions(body, say, logger):
logger.info(body)
say("What's up?")
@app.event("message")
def handle_message():
pass
from fastapi import FastAPI, Request
api = FastAPI()
@api.post("/slack/events")
async def endpoint(req: Request):
return await app_handler.handle(req)
@api.get("/slack/install")
async def install(req: Request):
return await app_handler.handle(req)
@api.get("/slack/oauth_redirect")
async def oauth_redirect(req: Request):
return await app_handler.handle(req)
# pip install -r requirements.txt
# # -- OAuth flow -- #
# export SLACK_SIGNING_SECRET=***
# export SLACK_CLIENT_ID=111.111
# export SLACK_CLIENT_SECRET=***
# export SLACK_SCOPES=app_mentions:read,channels:history,im:history,chat:write
# uvicorn oauth_app:api --reload --port 3000 --log-level warning