Authentication
All API endpoints require JWT (JSON Web Token) authentication using OAuth2 client credentials flow.
Contents
- Overview
- Obtain JWT Token
- Use JWT Token in API Requests
- Token Management
- Troubleshooting Authentication
Overview
Integration Steps:
- Authentication - Obtain JWT access token using OAuth2 client credentials
- API Request - Include JWT token in Authorization header
- Token Usage - Use the same token for multiple API calls until expiration
Remember
Ensure you have your client_id and client_secret from API Permissions
Step 1: Obtain JWT Token
Perform OAuth2 authentication by making a POST request to the authentication endpoint using your client_id and client_secret to retrieve a JWT access token.
Authentication Endpoint: https://central-monitoring-external-api-prod.auth.ap-southeast-2.amazoncognito.com/oauth2/token
Example Requests:
Python
import requests
data = {
"grant_type": "client_credentials",
"client_id": "{INSERT_CLIENT_ID}",
"client_secret": "{INSERT_CLIENT_SECRET}"
}
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(
"https://central-monitoring-external-api-prod.auth.ap-southeast-2.amazoncognito.com/oauth2/token",
data=data,
headers=headers
)
jwt_token = response.json()["access_token"]
Curl
curl -X POST "https://central-monitoring-external-api-prod.auth.ap-southeast-2.amazoncognito.com/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=insert_client_id" \
-d "client_secret=insert_client_secret" \
-d "grant_type=client_credentials"
Step 2: Use JWT Token in API Requests
Include the JWT token in the Authorization header for all API requests.
Example API Request:
Python
# Use the JWT token from step 1
headers = {
"Authorization": f"Bearer {jwt_token}",
"Content-Type": "application/json"
}
# Make API request. Sample Endpoint Used
response = requests.post(
"https://central-monitoring-prod.mywizard-aiops.com/v1/logs/batch",
json=payload,
headers=headers
)
Curl
curl -X POST "https://central-monitoring-prod.mywizard-aiops.com/v1/logs/batch" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"domain": "example.com", "time_range": "now-1d"}'
Token Management
- Token Expiration: JWT tokens have a 1 hour lifespan. Monitor for 401 Unauthorized responses and refresh tokens as needed.
- Token Reuse: The same token can be used for multiple API calls until it expires.
- Security: Store tokens securely and never expose them in client-side code or logs.
Troubleshooting Authentication
- 401 Unauthorized: Token is invalid, expired, or missing.
- 403 Forbidden: Token is valid but lacks required permissions.
- Invalid credentials: Verify your client_id and client_secret are correct.