mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-06 06:40:35 +01:00
Essai en de prise en compte du SSL
This commit is contained in:
@@ -25,6 +25,3 @@ def updateConfiguration():
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return redirect(request.referrer)
|
return redirect(request.referrer)
|
||||||
|
|
||||||
@webapp.route("/configurations/twitch/help")
|
|
||||||
def twitchConfigurationHelp():
|
|
||||||
return render_template("twitch-aide.html", token_redirect_url = f'{request.url_root[:-1]}{url_for('twitchReceiveToken')}')
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import request, redirect, url_for
|
from flask import render_template, request, redirect, url_for
|
||||||
from twitchAPI.twitch import Twitch
|
from twitchAPI.twitch import Twitch
|
||||||
from twitchAPI.type import TwitchAPIException
|
from twitchAPI.type import TwitchAPIException
|
||||||
from twitchAPI.oauth import UserAuthenticator
|
from twitchAPI.oauth import UserAuthenticator
|
||||||
@@ -13,13 +13,16 @@ from webapp import webapp
|
|||||||
|
|
||||||
auth: UserAuthenticator
|
auth: UserAuthenticator
|
||||||
|
|
||||||
|
@webapp.route("/configurations/twitch/help")
|
||||||
|
def twitchConfigurationHelp():
|
||||||
|
return render_template("twitch-aide.html", token_redirect_url = _buildUrl())
|
||||||
|
|
||||||
@webapp.route("/configurations/twitch/request-token")
|
@webapp.route("/configurations/twitch/request-token")
|
||||||
async def twitchRequestToken():
|
async def twitchRequestToken():
|
||||||
global auth
|
global auth
|
||||||
url = f'{request.url_root[:-1]}{url_for('twitchReceiveToken')}'
|
|
||||||
helper = ConfigurationHelper()
|
helper = ConfigurationHelper()
|
||||||
twitch = await Twitch(helper.getValue('twitch_client_id'), helper.getValue('twitch_client_secret'))
|
twitch = await Twitch(helper.getValue('twitch_client_id'), helper.getValue('twitch_client_secret'))
|
||||||
auth = UserAuthenticator(twitch, USER_SCOPE, url=url)
|
auth = UserAuthenticator(twitch, USER_SCOPE, url=_buildUrl())
|
||||||
return redirect(auth.return_auth_url())
|
return redirect(auth.return_auth_url())
|
||||||
|
|
||||||
@webapp.route("/configurations/twitch/receive-token")
|
@webapp.route("/configurations/twitch/receive-token")
|
||||||
@@ -43,3 +46,10 @@ async def twitchReceiveToken():
|
|||||||
except TwitchAPIException as e:
|
except TwitchAPIException as e:
|
||||||
logging(e)
|
logging(e)
|
||||||
return redirect(url_for('openConfigurations'))
|
return redirect(url_for('openConfigurations'))
|
||||||
|
|
||||||
|
# hack pas fou mais on estime qu'on sera toujours en ssl en connecté
|
||||||
|
def _buildUrl():
|
||||||
|
url = f'{request.url_root[:-1]}{url_for('twitchReceiveToken')}'
|
||||||
|
if url.find('localhost') != -1 : return url
|
||||||
|
url = url.replace('http://', 'https://')
|
||||||
|
return url
|
||||||
|
|||||||
Reference in New Issue
Block a user