Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(accounting): surface real OAuth error in token refresh failures (#1636)

Brad Barbinda6833cb9345
diff --git a/packages/ee/src/accounting/core/utils.ts b/packages/ee/src/accounting/core/utils.ts
index 41f209396b..083bfe4edb 100644
--- a/packages/ee/src/accounting/core/utils.ts
+++ b/packages/ee/src/accounting/core/utils.ts
@@ -503,12 +503,21 @@ export function createOAuthClient({
})
});
- if (response.error || !response.data) {
+ if (response.error || !response.data?.access_token) {
logger.error("Token refresh failed", {
- error: response.error,
+ code: response.code,
+ message: response.message,
data: response.data
});
- throw new Error(`Token refresh failed: ${response.error}`);
+ // Surface the provider's actual rejection (e.g. invalid_grant /
+ // invalid_client) instead of the useless boolean "true".
+ throw new Error(
+ `Token refresh failed (HTTP ${response.code}): ${
+ typeof response.data === "string"
+ ? response.data
+ : JSON.stringify(response.data)
+ }`
+ );
}
const newCreds = {