Dropbox Integration
Overview
This skill provides read-only access to your Dropbox account, allowing you to browse folders, search files, and download content from OpenClaw. It uses OAuth 2.0 authentication with automatic token refresh for seamless long-term access.
Perfect for: Safely accessing your Dropbox files without worrying about accidental modifications or deletions.
Capabilities
Browse Files & Folders
- - List contents of any folder in your Dropbox
- View file sizes and modification dates
- Navigate folder hierarchies
Search Files
- - Full-text search across file names
- Find files anywhere in your Dropbox
- Get file metadata and locations
Download Files
- - Download any file from your Dropbox
- Save to local filesystem
- Batch download support
Automatic Token Management
- - OAuth 2.0 authentication with refresh tokens
- Automatic token refresh (no manual re-authentication)
- Secure credential storage
- Token expiration handling with 5-minute buffer
Security & Permissions
This skill is configured for read-only access with the following Dropbox scopes:
- -
files.metadata.read - Read file/folder metadata - INLINECODE1 - Read file content
- INLINECODE2 - Read account information
NOT included:
- - ❌
files.content.write - Cannot upload or modify files - ❌
files.metadata.write - Cannot rename or move files - ❌
files.permanent_delete - Cannot delete files
This ensures your Dropbox content remains safe from accidental modifications.
Prerequisites
Before using this skill, you need:
- 1. A Dropbox account (free or paid)
- A Dropbox App registration (takes 5 minutes)
- App key and App secret from your Dropbox App
- Node.js with
dropbox package (auto-installed)
Setup time: ~10 minutes
See Setup Guide for step-by-step instructions.
Quick Start
1. Create Dropbox App
Visit https://www.dropbox.com/developers/apps/create and create a new app:
- - API: Scoped access
- Access type: Full Dropbox (or App folder for restricted access)
- App name: Something unique like "OpenClaw-YourName"
2. Configure OAuth
In your app's settings:
- 1. Add redirect URI: INLINECODE7
- Copy your App key and App secret
- Under Permissions tab, enable:
-
files.metadata.read
-
files.content.read
- INLINECODE10
3. Save Credentials
Create credentials.json in the skill directory:
CODEBLOCK0
Important: This file is gitignored and will never be committed.
4. Run OAuth Setup
CODEBLOCK1
This will:
- 1. Open your browser for Dropbox authorization
- Start a local server to capture the authorization code
- Exchange the code for access + refresh tokens
- Save tokens securely to INLINECODE12
5. Test Connection
CODEBLOCK2
If successful, you'll see your Dropbox account information!
Usage Examples
Browse a Folder
CODEBLOCK3
Output:
CODEBLOCK4
Search Files
CODEBLOCK5
Output:
CODEBLOCK6
Download Files
CODEBLOCK7
Output:
CODEBLOCK8
Integration with OpenClaw
From OpenClaw, you can use the exec tool to run these scripts:
Browse files:
CODEBLOCK9
Search for files:
CODEBLOCK10
Download a file:
CODEBLOCK11
Or create custom automation workflows that use the dropbox-helper.js module directly.
How It Works
Authentication Flow
- 1. Initial Setup: User authorizes the app via OAuth 2.0
- Token Storage: Access token + refresh token saved to INLINECODE15
- Auto-Refresh: Before each API call, checks if token needs refresh
- Seamless Access: Automatically refreshes tokens 5 minutes before expiration
Token Lifecycle
- - Access Token: Short-lived (typically 4 hours)
- Refresh Token: Long-lived (doesn't expire unless revoked)
- Auto-refresh: Happens transparently in INLINECODE16
- Refresh Buffer: 5 minutes before expiration to prevent edge cases
File Structure
CODEBLOCK12
Troubleshooting
"credentials.json not found"
Create
credentials.json with your Dropbox app key and secret (see Quick Start step 3).
"Token refresh failed"
Your refresh token may have been revoked. Re-run
node setup-oauth.js to re-authenticate.
"Permission denied" errors
Check that you enabled the required permissions in your Dropbox App settings under the Permissions tab.
"redirecturimismatch"
Make sure you added
http://localhost:3000/callback to your app's redirect URIs in Dropbox App Console.
OAuth setup gets stuck
If the local server doesn't catch the redirect, manually copy the full URL from your browser after authorization and look for the
code= parameter.
Limitations
- - Read-only: Cannot upload, modify, or delete files (by design)
- File size: Practical limit ~150MB per download (Dropbox API constraint)
- Rate limits: Dropbox API has rate limits (typically not an issue for personal use)
- Shared folders: Access depends on your Dropbox account permissions
Security Best Practices
- 1. Never commit credentials:
credentials.json and token.json are gitignored - File permissions: Tokens are saved with mode 0600 (user read/write only)
- App-specific tokens: Each app has its own tokens (easily revokable)
- Scope limitation: Only request permissions you actually need
- Token rotation: Refresh tokens are rotated automatically
Resources
References
Dropbox Developer Resources
Advanced Usage
Using the Helper Module
For custom integrations, import the helper directly:
CODEBLOCK13
The helper automatically handles token refresh, so you never need to worry about expiration.
Batch Operations
Download multiple files in sequence:
CODEBLOCK14
Dependencies
This skill requires the dropbox npm package:
CODEBLOCK15
The package is automatically installed when you install this skill via ClawHub.
License
MIT - Free to use, modify, and distribute.
Support
For issues or questions:
Note: This skill is designed for personal use. For production applications with multiple users, consider implementing proper OAuth flow with state management and error handling for concurrent users.
Dropbox 集成
概述
此技能提供对您 Dropbox 账户的只读访问权限,允许您从 OpenClaw 浏览文件夹、搜索文件和下载内容。它使用 OAuth 2.0 认证,并带有自动令牌刷新功能,实现无缝的长期访问。
完美适用于: 安全访问您的 Dropbox 文件,无需担心意外修改或删除。
功能
浏览文件与文件夹
- - 列出 Dropbox 中任何文件夹的内容
- 查看文件大小和修改日期
- 导航文件夹层级
搜索文件
- - 对文件名进行全文搜索
- 在 Dropbox 中任意位置查找文件
- 获取文件元数据和位置
下载文件
- - 从 Dropbox 下载任意文件
- 保存到本地文件系统
- 支持批量下载
自动令牌管理
- - 使用刷新令牌的 OAuth 2.0 认证
- 自动令牌刷新(无需手动重新认证)
- 安全凭据存储
- 令牌过期处理,带 5 分钟缓冲
安全与权限
此技能配置为只读访问,使用以下 Dropbox 作用域:
- - files.metadata.read - 读取文件/文件夹元数据
- files.content.read - 读取文件内容
- account_info.read - 读取账户信息
不包括:
- - ❌ files.content.write - 无法上传或修改文件
- ❌ files.metadata.write - 无法重命名或移动文件
- ❌ files.permanent_delete - 无法删除文件
这确保您的 Dropbox 内容免受意外修改。
前提条件
使用此技能前,您需要:
- 1. 一个 Dropbox 账户(免费或付费)
- 一个 Dropbox 应用注册(需 5 分钟)
- 来自 Dropbox 应用的 应用密钥 和 应用密码
- 安装了 dropbox 包的 Node.js(自动安装)
设置时间:约 10 分钟
请参阅 设置指南 获取分步说明。
快速开始
1. 创建 Dropbox 应用
访问 https://www.dropbox.com/developers/apps/create 并创建一个新应用:
- - API: 作用域访问
- 访问类型: 完整 Dropbox(或应用文件夹用于受限访问)
- 应用名称: 一个唯一的名称,如 OpenClaw-YourName
2. 配置 OAuth
在应用设置中:
- 1. 添加重定向 URI:http://localhost:3000/callback
- 复制您的 应用密钥 和 应用密码
- 在 权限 标签页中,启用:
- files.metadata.read
- files.content.read
- account_info.read
3. 保存凭据
在技能目录中创建 credentials.json:
json
{
appkey: yourdropboxappkey_here,
appsecret: yourdropboxappsecret_here
}
重要: 此文件已被 gitignore 忽略,永远不会被提交。
4. 运行 OAuth 设置
bash
node setup-oauth.js
这将:
- 1. 打开浏览器进行 Dropbox 授权
- 启动本地服务器以捕获授权码
- 将授权码交换为访问令牌 + 刷新令牌
- 将令牌安全保存到 token.json
5. 测试连接
bash
node test-connection.js
如果成功,您将看到您的 Dropbox 账户信息!
使用示例
浏览文件夹
bash
列出根文件夹
node browse.js
列出特定文件夹
node browse.js /Documents
node browse.js /Photos/2024
输出:
📁 列出:/Documents
📄 report.pdf (2.3 MB) - 2024-02-01
📄 presentation.pptx (5.1 MB) - 2024-01-28
📁 Projects
📁 Archive
总计:4 个项目
搜索文件
bash
node search-files.js budget 2024
node search-files.js contract
输出:
🔍 搜索:budget 2024
✅ 找到 3 个匹配项:
📄 /Finance/budget-2024-q1.xlsx
大小:156.3 KB
修改时间:2024-01-15T10:30:00Z
📄 /Reports/budget-2024-summary.pdf
大小:2.1 MB
修改时间:2024-02-01T14:22:00Z
下载文件
bash
下载到本地文件
node download.js /Documents/report.pdf ./downloads/report.pdf
下载到当前目录
node download.js /Photos/vacation.jpg ./vacation.jpg
输出:
📥 下载中:/Documents/report.pdf
✅ 保存到:./downloads/report.pdf (2.3 MB)
与 OpenClaw 集成
从 OpenClaw,您可以使用 exec 工具运行这些脚本:
浏览文件:
运行:node /path/to/dropbox-integration/browse.js /Documents
搜索文件:
运行:node /path/to/dropbox-integration/search-files.js contract
下载文件:
运行:node /path/to/dropbox-integration/download.js /path/in/dropbox ./local/path
或者创建直接使用 dropbox-helper.js 模块的自定义自动化工作流。
工作原理
认证流程
- 1. 初始设置: 用户通过 OAuth 2.0 授权应用
- 令牌存储: 访问令牌 + 刷新令牌保存到 token.json
- 自动刷新: 每次 API 调用前,检查令牌是否需要刷新
- 无缝访问: 在过期前 5 分钟自动刷新令牌
令牌生命周期
- - 访问令牌: 短期有效(通常 4 小时)
- 刷新令牌: 长期有效(除非撤销,否则不过期)
- 自动刷新: 在 dropbox-helper.js 中透明执行
- 刷新缓冲: 过期前 5 分钟,防止边界情况
文件结构
dropbox-integration/
├── SKILL.md # 本文件
├── dropbox-helper.js # 自动刷新 Dropbox 客户端
├── setup-oauth.js # OAuth 设置脚本
├── browse.js # 浏览文件夹
├── search-files.js # 搜索文件
├── download.js # 下载文件
├── test-connection.js # 测试认证
├── credentials.json.example # 凭据模板
├── .gitignore # 排除 credentials.json 和 token.json
└── references/
└── setup-guide.md # 详细设置说明
故障排除
credentials.json not found
创建包含 Dropbox 应用密钥和密码的 credentials.json(参见快速开始步骤 3)。
Token refresh failed
您的刷新令牌可能已被撤销。重新运行 node setup-oauth.js 以重新认证。
Permission denied 错误
检查您是否在 Dropbox 应用设置的权限标签页中启用了所需权限。
redirecturimismatch
确保您在 Dropbox 应用控制台的应用重定向 URI 中添加了 http://localhost:3000/callback。
OAuth 设置卡住
如果本地服务器没有捕获重定向,请在授权后手动从浏览器复制完整 URL,并查找 code= 参数。
限制
- - 只读: 无法上传、修改或删除文件(设计如此)
- 文件大小: 每次下载约 150MB 的实际限制(Dropbox API 约束)
- 速率限制: Dropbox API 有速率限制(个人使用通常不是问题)
- 共享文件夹: 访问取决于您的 Dropbox 账户权限
安全最佳实践
- 1. 切勿提交凭据: credentials.json 和 token.json 已被 gitignore 忽略
- 文件权限: 令牌以模式 0600 保存(仅用户读/写)
- 应用特定令牌: 每个应用有自己的令牌(易于撤销)
- 作用域限制: 仅请求您实际需要的权限
- 令牌轮换: 刷新令牌自动轮换
资源
参考
###