Skip to main content
Secure access to the Olimi API is crucial for protecting your data and ensuring the integrity of your communications. This guide will walk you through the authentication process for the Olimi API.

Authentication Method

Olimi uses Bearer Token authentication for all API requests. This method is simple, secure, and widely supported across different platforms and programming languages.

Generating a Bearer Token

To authenticate with the Olimi API, you must first generate a bearer token using your API key. Follow these steps to generate the token programmatically:
  1. Make a POST request to the generate-token endpoint with your API key. Here’s the format of the request: Endpoint: {{base_url}}/api/generate-token
    Method: POST
    Body (JSON):
    {
      "apiKey": "YOUR_API_KEY"
    }
    
    Replace YOUR_API_KEY with your actual API key.
    
    
  2. Upon successful authentication, you’ll receive a JSON response containing the bearer token.
Example Request:
 curl -X POST {{base_url}}/api/generate-token -H "Content-Type: application/json" -d '{"apiKey": "YOUR_API_KEY"}'
Example Response:
{
"success": true,
"message": "Requested Successfully",
"token": "Your Bearer Token",
"expiresAt": "2024-10-15 09:50:01"
}

Using the Bearer Token

Include your bearer token in the Authorization header of each API request:
Authorization: Bearer YOUR_BEARER_TOKEN
Example using cURL:
curl -H "Authorization: Bearer YOUR_BEARER_TOKEN" https://api.olimi.com/v1/endpoint
Example using JavaScript (with fetch):
fetch('https://api.olimi.com/v1/endpoint', {
  headers: {
    'Authorization': 'Bearer YOUR_BEARER_TOKEN'
  }
})
.then(response => response.json())
.then(data => console.log(data));

Best Practices

To ensure the security of your Olimi account and data, follow these best practices:
  1. Keep your token secure: Never share your bearer token publicly or commit it to version control systems.
  2. Use environment variables: Store your bearer token in environment variables rather than hardcoding it in your application.
  3. Implement token rotation: Regularly generate new tokens and update your applications to use the new tokens.
  4. Use HTTPS: Always use HTTPS for API communications to ensure data privacy and prevent man-in-the-middle attacks.
  5. Minimize token exposure: Only use your bearer token in server-side code. Never use it in client-side JavaScript that runs in a user’s browser.

Error Handling

If your authentication fails, you’ll receive a 401 Unauthorized HTTP status code. Common reasons for authentication failures include:
  • Invalid bearer token
  • Expired bearer token
  • Incorrectly formatted Authorization header
Always check for and handle authentication errors in your applications.

Support

If you encounter any issues with authentication or need further assistance, please customer our support team at support@olimi.com. Remember, your bearer token is the key to your Olimi account’s API access. Keep it confidential and secure at all times.
I