Skip to content

Commit bd9d859

Browse files
committed
fix: return callback HTML with text/html content-type
1 parent 65bcfda commit bd9d859

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

oauth/app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from litestar.openapi.plugins import ScalarRenderPlugin
1212
from litestar.openapi.spec import Contact, ExternalDocumentation, License, Server
1313
from litestar.response import Redirect
14+
from litestar.response.base import ASGIResponse
1415

1516
# Load .env from oauth/ or repo root if present
1617
_env_file = Path(__file__).parent / ".env"
@@ -53,8 +54,8 @@ async def auth() -> Redirect:
5354
return Redirect(f"{AUTHORIZE_URL}?client_id={CLIENT_ID}&scope=repo,user")
5455

5556

56-
@get("/callback")
57-
async def callback(code: str) -> str:
57+
@get("/callback", media_type="text/html")
58+
async def callback(code: str) -> ASGIResponse:
5859
async with httpx.AsyncClient() as client:
5960
resp = await client.post(
6061
TOKEN_URL,
@@ -63,7 +64,7 @@ async def callback(code: str) -> str:
6364
)
6465
resp.raise_for_status()
6566
token = resp.json()["access_token"]
66-
return CALLBACK_HTML % token
67+
return ASGIResponse(body=(CALLBACK_HTML % token).encode(), media_type="text/html")
6768

6869

6970
app = Litestar(

0 commit comments

Comments
 (0)