diff --git a/src/workforce.js b/src/workforce.js index 2640026..9fc9436 100644 --- a/src/workforce.js +++ b/src/workforce.js @@ -31,11 +31,14 @@ async function getWorkforceToken() { grant_type: 'password', username: creds.email, password: creds.password, - scope: 'me department staff', + scope: 'me department', }).toString(), signal: AbortSignal.timeout(10000), }) - if (!res.ok) throw new Error(`Workforce OAuth failed: ${res.status}`) + if (!res.ok) { + const body = await res.text().catch(() => '') + throw new Error(`Workforce OAuth failed: ${res.status}${body ? ': ' + body.slice(0, 300) : ''}`) + } const data = await res.json() _tokenCache = { access_token: data.access_token, base_url: baseUrl, expires_at: Date.now() + 50 * 60_000 } return { token: data.access_token, baseUrl }