Overview
This endpoint starts the OAuth authorization process for connecting a user to a wearable data provider. It returns an authorization URL where the user should be redirected to authenticate with the provider.
Call authorize endpoint
Request authorization URL with user ID and provider name
Redirect user
Send user to the returned authorization_url to authenticate
Provider redirects back
Provider redirects to callback endpoint with authorization code
Path Parameters
Provider identifier. Must be one of:
apple - Apple Health
samsung - Samsung Health
google - Google Fit
garmin - Garmin Connect
polar - Polar Flow
suunto - Suunto App
whoop - WHOOP
strava - Strava
oura - Oura Ring
Query Parameters
UUID of the user to connect to the provider
Optional URL to redirect to after successful authorization. If not provided, redirects to default success page.
Response
The OAuth authorization URL where the user should be redirected to authenticate
CSRF protection state parameter that will be validated in the callback
Examples
curl -X GET "https://api.openwearables.com/api/v1/oauth/garmin/authorize?user_id=123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer YOUR_API_KEY"
Response Example
{
"authorization_url": "https://connect.garmin.com/oauthConfirm?oauth_token=abc123def456&oauth_callback=https%3A%2F%2Fapi.openwearables.com%2Fapi%2Fv1%2Foauth%2Fgarmin%2Fcallback",
"state": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDAwIiwicHJvdmlkZXIiOiJnYXJtaW4ifQ"
}
Error Responses
HTTP status code indicating the error type
Human-readable error message
400 Bad Request
Returned when the provider does not support OAuth authentication.
{
"detail": "Provider 'apple' does not support OAuth"
}
422 Validation Error
Returned when required parameters are missing or invalid.
{
"detail": [
{
"type": "missing",
"loc": ["query", "user_id"],
"msg": "Field required"
}
]
}
OAuth Flow
After receiving the authorization URL:
- Redirect User: Send the user to the
authorization_url
- User Authenticates: User logs in and grants permissions on provider’s site
- Provider Redirects: Provider redirects back to the callback endpoint
- Token Exchange: Callback endpoint exchanges authorization code for access tokens
- Data Sync: Background job automatically syncs user’s health data
Notes
- The
state parameter is stored in Redis and validated during callback to prevent CSRF attacks
- State expires after 10 minutes if not used
- Some providers (like Apple Health) use SDK-based authentication and don’t support this OAuth flow
- The authorization URL format varies by provider but always includes necessary OAuth parameters