mirror of
https://github.com/MichaByte/OnBoard-Live.git
synced 2025-12-06 07:13:41 -05:00
Start work with OAuth
This commit is contained in:
parent
8308b22d89
commit
7e0ad4d1e2
2 changed files with 22 additions and 1 deletions
|
|
@ -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 ""
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@ requests
|
|||
python-dotenv
|
||||
prisma
|
||||
fastapi-utils
|
||||
httpx
|
||||
httpx
|
||||
apscheduler
|
||||
fastapi-oauth2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue