Fix Workforce connection test: use form-encoded OAuth body

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-02 00:35:55 +00:00
parent a886b4b30e
commit e84b916ecf

View file

@ -91,8 +91,8 @@ export async function integrationRoutes(app) {
const baseUrl = creds.base_url || 'https://my.workforce.com' const baseUrl = creds.base_url || 'https://my.workforce.com'
const res = await fetch(`${baseUrl}/api/oauth/token`, { const res = await fetch(`${baseUrl}/api/oauth/token`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: JSON.stringify({ grant_type: 'password', username: creds.email, password: creds.password, scope: 'default' }), body: new URLSearchParams({ grant_type: 'password', username: creds.email, password: creds.password, scope: 'me' }).toString(),
signal: AbortSignal.timeout(8000), signal: AbortSignal.timeout(8000),
}) })
if (!res.ok) throw new Error(`Workforce auth failed (${res.status})`) if (!res.ok) throw new Error(`Workforce auth failed (${res.status})`)