From ba97579f20004a453c5119dec8a7478d3d3b4e36 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Jun 2026 08:53:37 +0000 Subject: [PATCH] feat(farm-aggregator): add Dropbox connectivity test script Checks auth, lists root folder, and attempts a test upload to diagnose 400 errors (usually App Folder vs Full Dropbox access mismatch). Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01KBD2dN2KEjzz3UQFa9hEpu --- farm-aggregator/scripts/dropbox-test.js | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 farm-aggregator/scripts/dropbox-test.js diff --git a/farm-aggregator/scripts/dropbox-test.js b/farm-aggregator/scripts/dropbox-test.js new file mode 100644 index 0000000..ed77084 --- /dev/null +++ b/farm-aggregator/scripts/dropbox-test.js @@ -0,0 +1,54 @@ +/** + * Tests Dropbox connectivity and upload access. + * Run: node scripts/dropbox-test.js + */ +import 'dotenv/config'; +import { Dropbox } from 'dropbox'; + +const dbx = new Dropbox({ + clientId: process.env.DROPBOX_APP_KEY, + clientSecret: process.env.DROPBOX_APP_SECRET, + refreshToken: process.env.DROPBOX_REFRESH_TOKEN, +}); + +async function run() { + // 1. Check account info + try { + const account = await dbx.usersGetCurrentAccount(); + console.log('โœ… Connected as:', account.result.name.display_name); + } catch (e) { + console.error('โŒ Auth failed:', e.message); + process.exit(1); + } + + // 2. Try listing root + try { + const root = await dbx.filesListFolder({ path: '' }); + console.log('\n๐Ÿ“ Root folder contents:'); + root.result.entries.forEach((e) => console.log(' ', e['.tag'] === 'folder' ? '๐Ÿ“' : '๐Ÿ“„', e.name)); + } catch (e) { + console.error('โŒ Cannot list root:', e.message); + } + + // 3. Try uploading a test file to /Farm/Summaries + const outbox = process.env.DROPBOX_OUTBOX_PATH ?? '/Farm/Summaries'; + const testPath = `${outbox}/test_${Date.now()}.txt`; + try { + await dbx.filesUpload({ + path: testPath, + contents: `Test upload at ${new Date().toISOString()}`, + mode: { '.tag': 'overwrite' }, + }); + console.log(`\nโœ… Upload succeeded โ†’ ${testPath}`); + // Clean up + await dbx.filesDeleteV2({ path: testPath }); + console.log('๐Ÿงน Test file cleaned up'); + } catch (e) { + console.error(`\nโŒ Upload to ${testPath} failed:`, e.message ?? e); + console.log('\nโ†’ If this is a 400/path error, your Dropbox app likely has App Folder access only.'); + console.log(' Fix: go to dropbox.com/developers โ†’ your app โ†’ Permissions โ†’ change to Full Dropbox'); + console.log(' Then regenerate your refresh token (run dropbox-auth.js again).'); + } +} + +run();