Workflow: OAuth Source Onboarding
This workflow shows provider OAuth onboarding from URL generation through source sync.
When To Use
- Connecting Google Drive/SharePoint/other OAuth-backed providers.
- Re-authing after expired or revoked OAuth credentials.
Step 1: Request OAuth URL
dodil k3 \
credential oauth-url --provider-id google_drive -o jsonExpected output includes:
auth_urlstate
Step 2: Authorize in browser
- Open
auth_url. - Complete provider consent.
- Capture returned authorization
code. - Keep
statefor validation if your flow enforces it.
Step 3: Exchange code for credential
dodil k3 \
credential oauth-exchange \
--provider-id google_drive \
--code "<oauth_code>" \
--redirect-uri "https://app.example.com/k3/oauth/callback" \
--state "<state>" \
--display-name "google-drive-main"Capture credential_id.
Step 4: Create source (API-rich path)
Use API if you need provider details and scheduling in one request:
curl -sS -X POST "https://k3.dev.dodil.io/$K3_BUCKET/sources" "${AUTH[@]}" "${JSON[@]}" \
-d '{
"bucket": "'$K3_BUCKET'",
"provider": "SOURCE_PROVIDER_GOOGLE_DRIVE",
"name": "drive-contracts",
"root_path": "/Contracts",
"provider_account": "drive-id-123",
"sync_interval_seconds": 3600,
"enabled": true
}'Step 5: Trigger discovery and ingestion
dodil k3 \
ingest trigger-discovery --bucket "$K3_BUCKET" --source <source_id>
dodil k3 \
ingest trigger --bucket "$K3_BUCKET" --source <source_id>Security and Operations Notes
- Never log raw OAuth codes/tokens in shared logs.
- Use
ValidateCredential/RefreshOAuthTokenAPI for long-lived operations. - Keep redirect URI exact match with provider app settings.