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.

refactor: add logging to onshape auth problem

Brad Barbin310a9c5dcd24
diff --git a/apps/erp/app/integrations/onshape/lib/client.ts b/apps/erp/app/integrations/onshape/lib/client.ts
index d0210816e1..b6a2e16f44 100644
--- a/apps/erp/app/integrations/onshape/lib/client.ts
+++ b/apps/erp/app/integrations/onshape/lib/client.ts
@@ -28,12 +28,14 @@ export class OnshapeClient {
* Generate the authorization headers for Onshape API requests
*/
private getAuthHeaders(): Record<string, string> {
+ const auth = Buffer.from(`${this.accessKey}:${this.secretKey}`).toString(
+ "base64"
+ );
+ console.log("onshapedauth", auth);
return {
"Content-Type": "application/json",
Accept: "application/json;charset=UTF-8; qs=0.09",
- Authorization: `Basic ${Buffer.from(
- `${this.accessKey}:${this.secretKey}`
- ).toString("base64")}`,
+ Authorization: `Basic ${auth}`,
};
}
@@ -47,6 +49,7 @@ export class OnshapeClient {
): Promise<T> {
const headers = this.getAuthHeaders();
const url = `${this.baseUrl}${path}`;
+ console.log("onshapedurl", url);
const response = await fetch(url, {
method,
diff --git a/apps/erp/app/modules/shared/shared.service.ts b/apps/erp/app/modules/shared/shared.service.ts
index 8c355bd5bd..8b47e3164e 100644
--- a/apps/erp/app/modules/shared/shared.service.ts
+++ b/apps/erp/app/modules/shared/shared.service.ts
@@ -23,7 +23,7 @@ export async function getBase64ImageFromSupabase(
) {
function arrayBufferToBase64(buffer: ArrayBuffer): string {
const binary = String.fromCharCode(...new Uint8Array(buffer));
- return btoa(binary);
+ return Buffer.from(binary).toString("base64");
}
const { data, error } = await client.storage.from("private").download(path);