Use me+department scopes and improve OAuth error messages

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-02 00:57:01 +00:00
parent f3dcfa37c6
commit 875835bb7c

View file

@ -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 }