Overview
Health device providers use OAuth for secure user authorization. Mirobody Health supports both OAuth 1.0 and OAuth 2.0 protocols.OAuth 1.0
Used by: Garmin, Fitbit (legacy)
OAuth 2.0
Used by: Whoop, Apple Health, most modern APIs
OAuth 2.0 Implementation
Most modern health APIs use OAuth 2.0. Here’s how to implement it:1. Initiate Authorization
2. Handle Callback
3. Token Refresh
OAuth 1.0 Implementation
Some providers (like Garmin) use OAuth 1.0:1. Request Token
2. Access Token Exchange
Security Best Practices
Token Storage
Token Storage
- Encrypt tokens before database storage
- Use secure key management (e.g., environment variables)
- Never log tokens or credentials
- Implement token rotation where supported
State Parameters
State Parameters
For OAuth 2.0:
- Generate cryptographically random state
- Store state temporarily (10-15 minutes TTL)
- Verify state in callback
- Prevent CSRF attacks
Error Handling
Error Handling
- Handle expired tokens gracefully
- Retry failed requests with exponential backoff
- Log errors without exposing sensitive data
- Provide clear error messages to users