clickup_v2
A comprehensive Rust client library and CLI for the ClickUp API v2, featuring OAuth2 authentication, full task management with custom fields support, and intelligent caching.
Features
- Complete OAuth2 Flow: Secure authentication with automatic token management
- Multi-Environment Support: Seamlessly works in development (local) and production (cloud) environments
- Task Management: Create, read, update, and delete tasks with full custom field support
- Entity Search: Search spaces, folders, lists, and tasks with intelligent caching (3-hour TTL)
- CLI Tool: Powerful command-line interface for all operations
- Type Safety: Fully typed API with comprehensive error handling
- Async/Await: Modern async Rust with Tokio runtime
Installation
As a Library
Add to your Cargo.toml:
[]
= "0.1.0"
As a CLI Tool
Install directly from crates.io:
Or clone and build locally:
Quick Start
Library Usage
use ;
async
CLI Usage
# Authenticate (first time setup)
# Get user info
# List all workspaces
# Create a task
# Search for entities
# Get tasks from a list
Environment Setup
Development Environment
Create a .env file in your project root:
# OAuth2 Credentials (required)
CLICKUP_CLIENT_ID=your_client_id
CLICKUP_CLIENT_SECRET=your_client_secret
CLICKUP_REDIRECT_URI=http://localhost:8888/callback
# Optional
CLICKUP_TEAM_ID=your_default_team_id
CLICKUP_API_URL=https://api.clickup.com/api/v2 # Custom API URL if needed
# Auto-populated after authentication
CLICKUP_ACCESS_TOKEN=your_access_token
The crate will automatically generate a template .env file if missing when you run it.
Production Environment
Set environment variables directly:
# Pre-authorized token
The crate automatically detects cloud environments (Google Cloud, AWS, Azure) and adjusts behavior accordingly.
Custom Fields Support
The library supports all ClickUp custom field types:
use CustomFieldValue;
// Text field
Text
// Number field
Number
// Date field (Unix timestamp in milliseconds)
Date
// Dropdown
DropdownOption
// Multiple options
DropdownOptions
// Checkbox
Checkbox
// Rating (1-5)
Rating
// And more: Email, Phone, URL, Location, etc.
API Coverage
Authentication
- OAuth2 flow with PKCE
- Token management and refresh
- Multi-environment support
User & Teams
- Get authorized user
- Get authorized teams/workspaces
Hierarchy Navigation
- Get/Search spaces
- Get/Search folders
- Get/Search lists
- Get/Search tasks
Task Management
- Create tasks with custom fields
- Update tasks
- Delete tasks
- Get task details
Caching
- 3-hour TTL cache for entity searches
- Cache invalidation
- Cache statistics
CI/CD Pipeline
This project uses GitHub Actions for continuous integration and deployment:
Automated Testing
- Multi-OS Testing: Ubuntu, macOS, Windows
- Rust Versions: Stable and Beta channels
- Security Audits: Automatic vulnerability scanning
- Code Quality: Rustfmt and Clippy checks
Automatic Publication
The crate is automatically published to crates.io when:
- Version is bumped in
Cargo.toml - Changes are pushed to the main branch
- All tests pass
Manual Release
For manual releases:
- Update version in
Cargo.toml - Push to main branch
- CI/CD will automatically:
- Run tests
- Create git tag
- Publish to crates.io
- Create GitHub release
Setting up CI/CD
-
Add these secrets to your GitHub repository:
CRATES_IO_TOKEN: Your crates.io API tokenCLICKUP_CLIENT_ID: For running tests (optional)CLICKUP_CLIENT_SECRET: For running tests (optional)CLICKUP_ACCESS_TOKEN: For running tests (optional)
-
The workflows will automatically run on:
- Push to main/master/develop branches
- Pull requests
- Manual workflow dispatch
Development
Building from Source
# Clone the repository
# Build the project
# Run tests
# Run with logging
RUST_LOG=debug
# Run clippy
# Format code
Running Tests
# Run all tests
# Run with output
# Run specific test
# Run integration tests (requires .env)
Debugging OAuth Flow
Enable debug logging to troubleshoot authentication:
RUST_LOG=debug
Key log markers:
🔑 Starting authentication- Auth flow begins🌐 Authorization URL generated- OAuth URL created⏳ Waiting for authorization- Callback server ready✅ Authorization code received- Callback successful🔄 Exchanging code for token- Token exchange
Architecture
Module Structure
src/
├── auth/
│ ├── oauth.rs # OAuth2 flow orchestration
│ ├── callback.rs # Local callback server
│ └── token.rs # Token management
├── client/
│ └── api.rs # ClickUp API client
├── config/
│ └── env.rs # Environment configuration
├── error/
│ └── auth_error.rs # Error types
├── lib.rs # Library interface
└── main.rs # CLI implementation
Key Design Patterns
- Builder Pattern: Request construction
- Type State Pattern: OAuth flow states
- Repository Pattern: Token persistence
- Strategy Pattern: Environment detection
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run
cargo fmtandcargo clippy - Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: docs.rs
Acknowledgments
Built with these amazing Rust crates:
- reqwest - HTTP client
- tokio - Async runtime
- oauth2 - OAuth2 implementation
- clap - CLI parsing
- serde - Serialization
Changelog
See CHANGELOG.md for version history.
Note: Replace yourusername with your actual GitHub username in URLs and badges.