Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Jun 22, 2024
1 parent 931af55 commit 251a7ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/adapters/osu_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
OSU_API_V2_TOKEN_ENDPOINT = "https://osu.ppy.sh/oauth/token"


def log_osu_api_request(request: httpx.Request) -> None:
async def log_osu_api_request(request: httpx.Request) -> None:
if request.url == OSU_API_V2_TOKEN_ENDPOINT:
return None

Expand All @@ -25,7 +25,7 @@ def log_osu_api_request(request: httpx.Request) -> None:
return None


http_client = httpx.AsyncClient(
osu_api_v2_http_client = httpx.AsyncClient(
base_url="https://osu.ppy.sh/api/v2/",
auth=oauth.AsyncOAuth(
client_id=settings.OSU_API_V2_CLIENT_ID,
Expand Down Expand Up @@ -93,7 +93,7 @@ class BeatmapExtended(Beatmap):


async def get_beatmap(beatmap_id: int) -> BeatmapExtended | None:
response = await http_client.get(f"beatmaps/{beatmap_id}")
response = await osu_api_v2_http_client.get(f"beatmaps/{beatmap_id}")
if response.status_code == 404:
return None
response.raise_for_status()
Expand Down Expand Up @@ -197,7 +197,7 @@ class Beatmapset(BaseModel):


async def get_beatmapset(beatmapset_id: int) -> Beatmapset | None:
response = await http_client.get(f"beatmapsets/{beatmapset_id}")
response = await osu_api_v2_http_client.get(f"beatmapsets/{beatmapset_id}")
if response.status_code == 404:
return None
response.raise_for_status()
Expand Down
5 changes: 5 additions & 0 deletions app/oauth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import AsyncGenerator
from collections.abc import Generator
from typing import Any

import httpx

Expand All @@ -10,13 +11,17 @@ def __init__(
client_id: str,
client_secret: str,
token_endpoint: str,
*args: Any,
**kwargs: Any,
) -> None:
self.client_id = client_id
self.client_secret = client_secret
self.token_endpoint = token_endpoint

self.access_token: str | None = None

super().__init__(*args, **kwargs)

def build_refresh_request(self) -> httpx.Request:
return httpx.Request(
"POST",
Expand Down

0 comments on commit 251a7ac

Please sign in to comment.