Designing OAuth Endpoints for Server-to-Server Calls
This guide captures the software-engineering principles WispHive expects integrators to follow when they POST authenticated users back to the platform or provision OAuth integrations programmatically.
Design principles
- Use stable, versioned URLs
- Prefer
/api/v1/...contracts for provisioning APIs.
- Prefer
- Keep browser and server responsibilities separate
- Browsers use
GET /oauth/start/{integration_id}. - Backends use signed callback POSTs to the returned
callback_url.
- Browsers use
- Require idempotency on write operations
- All callback POSTs must provide
Idempotency-Key.
- All callback POSTs must provide
- Protect all secrets server-side
- OAuth client secrets and
wisphive_tokenvalues must never be exposed in browser code.
- OAuth client secrets and
- Use strict URL validation
- Only
https://endpoints are accepted.
- Only
Recommended callback receiver pattern
Your backend should:
- Authenticate the user with your chosen IdP.
- Produce a stable UUID for the user.
- POST the result to the WispHive callback URL.
- Preserve the same
Idempotency-Keywhen retrying the same callback.
Retry guidance
- Retry
503responses with exponential backoff and jitter. - Do not retry
400responses unchanged. - Reuse the same
Idempotency-Keyonly when the payload is byte-for-byte equivalent.
Example callback request
curl -X POST "https://auth.samwifi.site/cp/rdt/cp-6a3e91fa6c1b/A29-U1N7W90A" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 5ec5f2b1-6f9e-46a4-b5de-37f00d16fb41" \
-d '{
"entity_name": "Acme SME",
"userid": "4d57d5f0-b73f-4d84-b5d2-a06d7701f931",
"display_name": "Jane Doe",
"email": "jane@example.com",
"provider_subject": "google-oauth2|103918273645",
"wisphive_token": "WH_Oid-a67d39t78sqcaRedsWte9_Kl90klhgyr37gHgfw-uiDlc35j9yUfa"
}'