aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-12-29 19:48:36 +0200
committerGravatar ks129 <[email protected]>2020-12-29 19:48:36 +0200
commitcf9cef443b597b6126eb11b51d9d7dabdee4e0d0 (patch)
treeae8553ab4f1ba1cefe1a882767f6d9522874fa7e
parentHandle ratelimits for role assigning (diff)
Use Discord API base URL from constants
-rw-r--r--backend/discord.py8
1 files 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}"
})