Workforce: bearer token only, remove email/password fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-07 12:42:49 +00:00
parent e758add8ae
commit 24f3fcdc7b
2 changed files with 7 additions and 20 deletions

View file

@ -30,7 +30,7 @@ export const INTEGRATIONS = {
workforce: {
name: 'Workforce',
configFields: ['base_url', 'sync_hours'],
secretFields: ['bearer_token', 'email', 'password'],
secretFields: ['bearer_token'],
},
smtp: {
name: 'SMTP Email',

View file

@ -88,26 +88,13 @@ export async function integrationRoutes(app) {
if (req.params.slug === 'newbook') await newbookTest(creds)
else if (req.params.slug === 'resos') await resosTest(creds)
else if (req.params.slug === 'workforce') {
if (!creds.bearer_token) throw new Error('Workforce bearer token not configured')
const baseUrl = creds.base_url || 'https://my.workforce.com'
if (creds.bearer_token) {
// Test bearer token directly with a lightweight API call
const res = await fetch(`${baseUrl}/api/v2/users?page=1&page_size=1`, {
const res = await fetch(`${baseUrl}/api/v2/users/me`, {
headers: { Authorization: `Bearer ${creds.bearer_token}` },
signal: AbortSignal.timeout(8000),
})
if (!res.ok) throw new Error(`Workforce bearer token invalid (${res.status})`)
} else {
if (!creds.email || !creds.password) throw new Error('No bearer token or email/password configured')
const res = await fetch(`${baseUrl}/api/oauth/token`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ grant_type: 'password', username: creds.email, password: creds.password, scope: 'platform' }).toString(),
signal: AbortSignal.timeout(8000),
})
if (!res.ok) throw new Error(`Workforce auth failed (${res.status})`)
const data = await res.json()
if (!data.access_token) throw new Error('No access token returned')
}
}
else if (req.params.slug === 'smtp') {
const nodemailer = await import('nodemailer')