earendil-works/pi · error · Error

Anthropic token refresh returned invalid JSON. url=${TOKEN_U

Error message

Anthropic token refresh returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}

What it means

Error "Anthropic token refresh returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}" thrown in earendil-works/pi.

Source

Thrown at packages/ai/src/auth/oauth/anthropic.ts:342

				client_id: CLIENT_ID,
				refresh_token: refreshToken,
			},
			signal,
		);
	} catch (error) {
		throw new Error(`Anthropic token refresh request failed. url=${TOKEN_URL}; details=${formatErrorDetails(error)}`);
	}

	let data: { access_token: string; refresh_token: string; expires_in: number; scope?: string };
	try {
		data = JSON.parse(responseBody) as {
			access_token: string;
			refresh_token: string;
			expires_in: number;
			scope?: string;
		};
	} catch (error) {
		throw new Error(
			`Anthropic token refresh returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}`,
		);
	}

	return {
		type: "oauth",
		refresh: data.refresh_token,
		access: data.access_token,
		expires: Date.now() + data.expires_in * 1000 - 5 * 60 * 1000,
	};
}

export const anthropicOAuth: OAuthAuth = {
	name: "Anthropic (Claude Pro/Max)",
	isSubscription: true,
	login: loginAnthropic,
	refresh: (credential, signal) => refreshAnthropicToken(credential.refresh, signal),

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Retry the refresh and inspect the body; re-login if the failure persists.

When it happens

Trigger: Thrown at packages/ai/src/auth/oauth/anthropic.ts:342 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/498dd21432403bef. Report an issue: GitHub.