authentication
Authentication Overview
The Ottimate API uses a two-layer authentication approach:
- X-API-Key: Required for all requests to identify your application
- OAuth2 Bearer Token: Required for accessing user-specific resources
How to send your first request
1. API Key
During early access, your Ottimate Partner Manager will issue you an API Key. Your API key determines your plan and API limits.
Important: The X-API-Key header must be included with every request to the Ottimate API.
2. OAuth2 Authentication
Ottimate uses the OAuth2 Authorization Code flow to authenticate users and access their resources. Your Ottimate Partner Manager will provide you with:
- Client ID: Identifies your application
- Client Secret: Secret key for your application (keep this secure!)
Available Scopes
Scopes define what permissions your application is requesting from the user. Currently supported scopes:
accounts.can_access_dashboard: Grants access to user dashboard and account information
OAuth2 Authorization Code Workflow
The Authorization Code flow is a secure method for obtaining access tokens. Here’s how it works:
Step 1: User Authorization
Redirect the user to Ottimate’s authorization endpoint in the browser:
Parameters:
response_type: Must becodeclient_id: Your application’s Client IDredirect_uri: URL where users will be redirected after authorizationscope: Permissions your application is requesting (e.g.,accounts.can_access_dashboard)state: Random string to prevent CSRF attacks
Step 2: User Consent
The user will be presented with a consent screen showing what permissions your application is requesting. After the user approves, they will be redirected to your redirect_uri with an authorization code:
Step 3: Exchange Code for Tokens
Your application exchanges the authorization code for an access token and refresh token:
Response:
Step 4: Use the Bearer Token
Include the access token in the Authorization header with the Bearer prefix for all API requests:
Refreshing Access Tokens
Access tokens expire after a certain period (typically 1 hour). Use the refresh token to obtain a new access token without requiring user interaction:
Response:
3. Making Authenticated Requests
Every request to the Ottimate API requires both authentication headers:
Best Practices
- Secure Storage: Never expose your Client Secret in client-side code
- Token Storage: Store access tokens and refresh tokens securely
- Token Refresh: Implement automatic token refresh before expiration
- Error Handling: Handle 401 Unauthorized responses by refreshing tokens
- State Parameter: Always use and validate the
stateparameter to prevent CSRF attacks

