Fix SambaPOS GraphQL token endpoint: /Token (SambaPOS OAuth) not /connect/token, GraphQL at /api/graphql
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e6470ad865
commit
d6449d8b52
1 changed files with 3 additions and 4 deletions
|
|
@ -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 }' }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue