mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 07:05:36 +01:00
Update twitch oauth
This commit is contained in:
6
.github/workflows/build_docker_image.yml
vendored
6
.github/workflows/build_docker_image.yml
vendored
@@ -66,3 +66,9 @@ jobs:
|
|||||||
uses: joelwmale/webhook-action@master
|
uses: joelwmale/webhook-action@master
|
||||||
with:
|
with:
|
||||||
url: ${{ secrets.WEBHOOK_URL_4 }}
|
url: ${{ secrets.WEBHOOK_URL_4 }}
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Invoke deployment hook (web_app)
|
||||||
|
uses: joelwmale/webhook-action@master
|
||||||
|
with:
|
||||||
|
url: ${{ secrets.WEBHOOK_URL_5 }}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
|
|
||||||
|
from twitchAPI.twitch import Twitch, AuthScope
|
||||||
|
from twitchAPI.helper import first
|
||||||
from httpx_oauth.oauth2 import OAuth2
|
from httpx_oauth.oauth2 import OAuth2
|
||||||
|
|
||||||
from core.config import config
|
from core.config import config
|
||||||
@@ -8,7 +10,25 @@ from core.config import config
|
|||||||
auth_router = APIRouter(prefix="/auth", tags=["auth"])
|
auth_router = APIRouter(prefix="/auth", tags=["auth"])
|
||||||
|
|
||||||
|
|
||||||
twitch_oauth = OAuth2(
|
class TwithOAuth2(OAuth2):
|
||||||
|
async def get_id_email(self, token: str):
|
||||||
|
twitch_client = Twitch(config.TWITCH_CLIENT_ID, config.TWITCH_CLIENT_SECRET)
|
||||||
|
|
||||||
|
await twitch_client.set_user_authentication(
|
||||||
|
token,
|
||||||
|
[AuthScope.USER_READ_EMAIL],
|
||||||
|
validate=True
|
||||||
|
)
|
||||||
|
|
||||||
|
me = await first(twitch_client.get_users())
|
||||||
|
|
||||||
|
if me is None:
|
||||||
|
raise Exception("Failed to get user data")
|
||||||
|
|
||||||
|
return me.id, me.email
|
||||||
|
|
||||||
|
|
||||||
|
twitch_oauth = TwithOAuth2(
|
||||||
config.TWITCH_CLIENT_ID,
|
config.TWITCH_CLIENT_ID,
|
||||||
config.TWITCH_CLIENT_SECRET,
|
config.TWITCH_CLIENT_SECRET,
|
||||||
"https://id.twitch.tv/oauth2/authorize",
|
"https://id.twitch.tv/oauth2/authorize",
|
||||||
|
|||||||
Reference in New Issue
Block a user