From 8502a190f80e1a5ad6933448c2d004543399aac8 Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Mon, 9 Mar 2026 17:35:13 -0700 Subject: [PATCH] fix claude auth --- packages/ai/src/utils/oauth/anthropic.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/ai/src/utils/oauth/anthropic.ts b/packages/ai/src/utils/oauth/anthropic.ts index 0f17917..89855c4 100644 --- a/packages/ai/src/utils/oauth/anthropic.ts +++ b/packages/ai/src/utils/oauth/anthropic.ts @@ -55,15 +55,15 @@ export async function loginAnthropic( const tokenResponse = await fetch(TOKEN_URL, { method: "POST", headers: { - "Content-Type": "application/json", + "Content-Type": "application/x-www-form-urlencoded", }, - body: JSON.stringify({ + body: new URLSearchParams({ grant_type: "authorization_code", client_id: CLIENT_ID, - code: code, - state: state, + code: code ?? "", redirect_uri: REDIRECT_URI, code_verifier: verifier, + ...(state ? { state } : {}), }), }); @@ -97,8 +97,8 @@ export async function refreshAnthropicToken( ): Promise { const response = await fetch(TOKEN_URL, { method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + body: new URLSearchParams({ grant_type: "refresh_token", client_id: CLIENT_ID, refresh_token: refreshToken,