Use me+department scopes and improve OAuth error messages
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f3dcfa37c6
commit
875835bb7c
1 changed files with 5 additions and 2 deletions
|
|
@ -31,11 +31,14 @@ async function getWorkforceToken() {
|
||||||
grant_type: 'password',
|
grant_type: 'password',
|
||||||
username: creds.email,
|
username: creds.email,
|
||||||
password: creds.password,
|
password: creds.password,
|
||||||
scope: 'me department staff',
|
scope: 'me department',
|
||||||
}).toString(),
|
}).toString(),
|
||||||
signal: AbortSignal.timeout(10000),
|
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()
|
const data = await res.json()
|
||||||
_tokenCache = { access_token: data.access_token, base_url: baseUrl, expires_at: Date.now() + 50 * 60_000 }
|
_tokenCache = { access_token: data.access_token, base_url: baseUrl, expires_at: Date.now() + 50 * 60_000 }
|
||||||
return { token: data.access_token, baseUrl }
|
return { token: data.access_token, baseUrl }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue