Complete guide to OAuth 2.0, API keys, token lifecycle, scopes, and security best practices.
Okinawa API v3 uses OAuth 2.0 as its primary authentication mechanism, with support for API keys for simpler use cases. Every API request must include a valid access token or API key in the Authorization header. This guide covers both approaches in detail, along with best practices for credential management, scope control, and security hardening.
Navigate to Settings → API Credentials in your Okinawa dashboard. From there, you can create two types of credentials:
When creating an OAuth application, you'll need to provide a redirect URI, a description, and the scopes your application requires. API keys can be created instantly with just a name and scope selection.
Okinawa supports the following OAuth 2.0 grant types, each designed for a specific use case:
Here's a complete example of the Authorization Code flow:
# Step 1: Redirect user to authorization URL\nGET https://auth.okinawa.com/authorize\n ?response_type=code\n &client_id=your_client_id\n &redirect_uri=https://yourapp.com/callback\n &scope=workflows:read workflows:execute\n &state=random_csrf_token\n &code_challenge=base64url(sha256(verifier))\n &code_challenge_method=S256
# Step 2: Exchange authorization code for tokens\nPOST https://auth.okinawa.com/token\nContent-Type: application/x-www-form-urlencoded\n\ngrant_type=authorization_code\n&code=received_auth_code\n&redirect_uri=https://yourapp.com/callback\n&client_id=your_client_id\n&code_verifier=original_verifier
# Response:\n{\n "access_token": "eyJhbGciOiJSUzI1NiIs...",\n "refresh_token": "rt_abc123def456...",\n "token_type": "Bearer",\n "expires_in": 3600,\n "scope": "workflows:read workflows:execute"\n}
Understanding token lifecycles is critical for building reliable integrations:
expires_in field in the token response and proactively refresh before expiration.Best practice: implement automatic token refresh in your application. Check the expires_in value and refresh when 5 minutes remain. This prevents unnecessary 401 errors.
Okinawa supports granular scopes for controlling API access. Scopes are requested during authorization and can be limited by organization administrators:
workflows:read — Read workflow definitions and execution historyworkflows:write — Create, update, and delete workflow definitionsworkflows:execute — Trigger workflow runs manuallyintegrations:read — View connected integrations and their statusintegrations:write — Connect, disconnect, and configure integrationsagents:read — View agent configurations and execution logsagents:manage — Create, update, and delete agentssecrets:read — Access secret names (never values)secrets:write — Create and update secretsadmin:full — Full administrative access to all resourcesFor simpler use cases, API keys provide a straightforward alternative to OAuth:
curl -X GET https://api.okinawa.com/v3/workflows \\\n -H "Authorization: Bearer ok_api_abc123def456" \\\n -H "Content-Type: application/json"
API keys don't expire but can be revoked instantly from the dashboard. Each key has an associated set of scopes that determines what it can access. You can create multiple keys with different scopes for different parts of your infrastructure.
X-Okinawa-Signature header on incoming webhooks using your webhook secret to ensure requests are genuinely from Okinawa.