From a4ff394695fcd0a00ca9242151625628b170b277 Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Sat, 29 Nov 2025 14:23:37 +0800 Subject: [PATCH] fix: Change OAuth token request body to `x-www-form-urlencoded` format. --- app/api/oauth/callback/route.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/api/oauth/callback/route.ts b/app/api/oauth/callback/route.ts index 92799bb..66c2ad7 100644 --- a/app/api/oauth/callback/route.ts +++ b/app/api/oauth/callback/route.ts @@ -25,14 +25,16 @@ export async function GET(request: NextRequest) { console.log('[OAuth Callback] Exchanging code for token...'); const tokenResponse = await fetch('https://connect.linux.do/oauth2/token', { method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: new URLSearchParams({ client_id: CLIENT_ID, client_secret: CLIENT_SECRET, code, redirect_uri: REDIRECT_URI, grant_type: 'authorization_code', - }), + }).toString(), }); const tokenData = await tokenResponse.json();