From cf9cef443b597b6126eb11b51d9d7dabdee4e0d0 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Tue, 29 Dec 2020 19:48:36 +0200 Subject: Use Discord API base URL from constants --- backend/discord.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/discord.py b/backend/discord.py index d6310b7..1dc8ed7 100644 --- a/backend/discord.py +++ b/backend/discord.py @@ -2,11 +2,9 @@ import httpx from backend.constants import ( - OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRET, OAUTH2_REDIRECT_URI + DISCORD_API_BASE_URL, OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRET, OAUTH2_REDIRECT_URI ) -API_BASE_URL = "https://discord.com/api/v8" - async def fetch_bearer_token(access_code: str) -> dict: async with httpx.AsyncClient() as client: @@ -18,7 +16,7 @@ async def fetch_bearer_token(access_code: str) -> dict: "redirect_uri": OAUTH2_REDIRECT_URI } - r = await client.post(f"{API_BASE_URL}/oauth2/token", headers={ + r = await client.post(f"{DISCORD_API_BASE_URL}/oauth2/token", headers={ "Content-Type": "application/x-www-form-urlencoded" }, data=data) @@ -29,7 +27,7 @@ async def fetch_bearer_token(access_code: str) -> dict: async def fetch_user_details(bearer_token: str) -> dict: async with httpx.AsyncClient() as client: - r = await client.get(f"{API_BASE_URL}/users/@me", headers={ + r = await client.get(f"{DISCORD_API_BASE_URL}/users/@me", headers={ "Authorization": f"Bearer {bearer_token}" }) -- cgit v1.2.3