diff --git a/backend/main.py b/backend/main.py index 71f0030..6cb1918 100644 --- a/backend/main.py +++ b/backend/main.py @@ -11,9 +11,13 @@ from apscheduler.triggers.interval import IntervalTrigger from dotenv import load_dotenv from fastapi import FastAPI, Request, Response from fastapi.middleware.cors import CORSMiddleware +from fastapi_oauth2.claims import Claims +from fastapi_oauth2.client import OAuth2Client +from fastapi_oauth2.config import OAuth2Config from prisma import Prisma from slack_bolt.adapter.fastapi.async_handler import AsyncSlackRequestHandler from slack_bolt.async_app import AsyncAck, AsyncApp +from social_core.backends.slack import SlackOAuth2 load_dotenv() @@ -22,6 +26,20 @@ active_streams: List[Dict[str, str | bool]] = [] scheduler = AsyncIOScheduler() +oauth2_config = OAuth2Config( + allow_http=False, + jwt_secret=os.getenv("JWT_SECRET"), + jwt_expires=os.getenv("JWT_EXPIRES"), + jwt_algorithm=os.getenv("JWT_ALGORITHM"), + clients=[ + OAuth2Client( + backend=SlackOAuth2, + client_id=os.environ["SLACK_TOKEN"], + client_secret=os.environ["SLACK_SIGNING_SECRET"], + ) + ], +) + async def update_active(): global active_stream @@ -146,6 +164,7 @@ async def get_stream_by_key(stream_key: str): stream if stream else Response(status_code=404, content="404: Stream not found") ) + @api.get("/api/v1/active_stream") async def get_active_stream(): return active_stream["name"] if "name" in active_stream else "" diff --git a/requirements.txt b/requirements.txt index b5a1063..598a42f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,6 @@ requests python-dotenv prisma fastapi-utils -httpx \ No newline at end of file +httpx +apscheduler +fastapi-oauth2