From d6449d8b52baff3c5270fb87ec1aed3c4efe84fe Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 14 Jul 2026 13:40:09 +0000 Subject: [PATCH] Fix SambaPOS GraphQL token endpoint: /Token (SambaPOS OAuth) not /connect/token, GraphQL at /api/graphql Co-Authored-By: Claude Sonnet 4.6 --- src/routes/integrations.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routes/integrations.js b/src/routes/integrations.js index b4db783..47a316a 100644 --- a/src/routes/integrations.js +++ b/src/routes/integrations.js @@ -161,8 +161,8 @@ export async function integrationRoutes(app) { try { if (!creds.graphql_endpoint || !creds.graphql_username || !creds.graphql_password || !creds.graphql_client_id) throw new Error('GraphQL endpoint, username, password and client ID are required') - const origin = new URL(creds.graphql_endpoint).origin - const tokenRes = await fetch(`${origin}/connect/token`, { + const base = creds.graphql_endpoint.replace(/\/$/, '') + const tokenRes = await fetch(`${base}/Token`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ @@ -170,14 +170,13 @@ export async function integrationRoutes(app) { username: creds.graphql_username, password: creds.graphql_password, client_id: creds.graphql_client_id, - scope: 'api', }), signal: AbortSignal.timeout(8000), }) if (!tokenRes.ok) throw new Error(`Token request failed (${tokenRes.status})`) const { access_token } = await tokenRes.json() if (!access_token) throw new Error('No access token returned') - const gqlRes = await fetch(creds.graphql_endpoint.replace(/\/$/, ''), { + const gqlRes = await fetch(`${base}/api/graphql`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${access_token}` }, body: JSON.stringify({ query: '{ __typename }' }),