This document describes the Intervals.icu integration added to the SmartSpin2k configuration app.
- Secure OAuth 2.0 flow for connecting to Intervals.icu
- Token management with automatic refresh
- Persistent authentication state across app sessions
- Fetch today's planned workout from Intervals.icu
- Automatic conversion from Intervals.icu format to ZWO format
- Support for structured workouts with intervals, ramps, and steady states
- Upload completed workouts to Intervals.icu as FIT files
- Integration with existing workout export dialog
- Automatic workout metadata (name, description)
- Connected Accounts dialog for authentication management
- Workout menu option to load today's workout
- Status indicators for connection state
To use Intervals.icu integration, you need to obtain API credentials:
- Go to Intervals.icu API Settings
- Create a new OAuth application
- Set the redirect URI to:
smartspin2k://intervals_redirect - Note down your Client ID and Client Secret
Add your credentials to the environment configuration:
For local development:
- Copy
lib/config/env.template.darttolib/config/env.local.dart - Replace the placeholder values:
static const String intervalsClientId = 'your_actual_client_id';
static const String intervalsClientSecret = 'your_actual_client_secret';For CI/CD builds: Set environment variables:
INTERVALS_CLIENT_IDINTERVALS_CLIENT_SECRET
- In the workout screen, tap the menu (⋮) button
- Select "Connected Accounts"
- Tap "Connect with Intervals.icu"
- Complete the OAuth flow in your browser
- Return to the app when prompted
- Ensure you're connected to Intervals.icu
- In the workout screen, tap the menu (⋮) button
- Select "Today's Workout (Intervals.icu)"
- The workout will be loaded automatically if available
- Complete a workout session
- When the workout ends, tap "Export"
- Select "UPLOAD TO INTERVALS.ICU"
- The workout will be uploaded as a FIT file
- Authentication:
https://intervals.icu/oauth/authorizeandhttps://intervals.icu/api/oauth/token - Today's Events:
GET /api/v1/athlete/{id}/events/{date} - Upload Activity:
POST /api/v1/athlete/{id}/activities - Workout Library:
GET /api/v1/athlete/{id}/workouts
The integration supports:
- Structured workouts from Intervals.icu
- ZWO format files
- Automatic conversion between formats
- Workout metadata (name, description, duration, TSS, IF)
The integration includes comprehensive error handling for:
- Network connectivity issues
- Authentication failures
- Invalid workout formats
- API rate limiting
- Missing workout data
- OAuth 2.0 with PKCE (if supported)
- Secure token storage using SharedPreferences
- Automatic token refresh
- No credentials stored in code or logs