Authentication and Authorization
Overview
To securely access resources via the WatchEye API, clients are required to authenticate using API keys. These tokens serve as credentials, ensuring only authorized entities can interact with the API. This section outlines the process of obtaining, using, and managing these tokens.
Generating an API Key
- Visit the WatchEye portal: https://portal.watcheye.com.au
- Log in with your registered credentials.
- Navigate to the Account -> API Keys section.
- From here, you can generate one or multiple API keys as per your requirement.
When an API key is created, both the API key and secret will be displayed. You must note down the secret as it will not be displayed again.
Using Your API Key
Once you have your API key and API Secret, include them in the request header when making API calls. The Authorization header format is as follows:
Authorization: Bearer <your-api-key>|<your-api-secret>
Replace <your-api-key> with your actual API key and <your-api-secret> with your actual API secret. Note that they are separated by a pipe character.
Handling Authentication Failures
If a request is made with an invalid, expired, or missing key or secret, the API will respond with a 401 Unauthorized status. This indicates that the server understands the request but refuses to authorize it. When you receive such a response:
- Double-check the key and secret you've provided in the
Authorizationheader. - Ensure that any IP address or subnet restrictions you've set up align with the IP address making the request.
- If you suspect the key or secret has been compromised, generate a new one from the WatchEye portal and replace the old one in your application.
Best Practices
-
Store API keys securely: Treat your API keys and secrets like passwords. Store them securely, and avoid hardcoding them directly in your code.
-
Regularly rotate keys and secrets: For added security, consider rotating your API keys and secrets periodically.
-
Monitor for unauthorized access: Monitor your API usage for any unexpected or unauthorized activity.
Following these guidelines will help maintain the integrity and security of your interactions with the WatchEye API.