Fix Workforce OAuth: use form-encoded body and correct scope

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 42be29b2ce
commit 1eba56345f

View file

@ -26,13 +26,13 @@ async function getWorkforceToken() {
} }
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({ body: new URLSearchParams({
grant_type: 'password', grant_type: 'password',
username: creds.email, username: creds.email,
password: creds.password, password: creds.password,
scope: 'default', scope: 'me',
}), }).toString(),
signal: AbortSignal.timeout(10000), signal: AbortSignal.timeout(10000),
}) })
if (!res.ok) throw new Error(`Workforce OAuth failed: ${res.status}`) if (!res.ok) throw new Error(`Workforce OAuth failed: ${res.status}`)