aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/route_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'pysite/route_manager.py')
-rw-r--r--pysite/route_manager.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pysite/route_manager.py b/pysite/route_manager.py
index 72517a3c..9ecd3ced 100644
--- a/pysite/route_manager.py
+++ b/pysite/route_manager.py
@@ -5,10 +5,15 @@ import logging
import os
from flask import Blueprint, Flask
+from flask_dance.contrib.discord import make_discord_blueprint
from flask_sockets import Sockets
from pysite.base_route import APIView, BaseView, ErrorView, RouteView
+from pysite.constants import (
+ DISCORD_OAUTH_ID, DISCORD_OAUTH_SCOPE, DISCORD_OAUTH_SECRET, DISCORD_OAUTH_REDIRECT, DISCORD_OAUTH_AUTHORIZED
+)
from pysite.database import RethinkDB
+from pysite.oauth import OauthBackend
from pysite.websockets import WS
TEMPLATES_PATH = "../templates"
@@ -31,6 +36,21 @@ class RouteManager:
self.app.before_request(self.db.before_request)
self.app.teardown_request(self.db.teardown_request)
+ # Load the oauth blueprint
+ self.oauth_backend = OauthBackend(self)
+ self.oauth_blueprint = make_discord_blueprint(
+ DISCORD_OAUTH_ID,
+ DISCORD_OAUTH_SECRET,
+ DISCORD_OAUTH_SCOPE,
+ '/',
+ login_url=DISCORD_OAUTH_REDIRECT,
+ authorized_url=DISCORD_OAUTH_AUTHORIZED,
+ backend=self.oauth_backend
+ )
+ self.log.debug(f"Loading Blueprint: {self.oauth_blueprint.name}")
+ self.app.register_blueprint(self.oauth_blueprint)
+ self.log.debug("")
+
# Load the main blueprint
self.main_blueprint = Blueprint("main", __name__)
self.log.debug(f"Loading Blueprint: {self.main_blueprint.name}")