GET /api/v1/admin/metrics • HTTP 200 OK
HTTP Basic Auth API Example (Base64 Credentials) — Request & Response Example
Demonstrates legacy yet ubiquitous HTTP Basic Authentication where client credentials are encoded as Base64 in the Authorization header.
1. HTTP Client Request (GET)
GET /api/v1/admin/metrics HTTP/1.1
{
"Authorization": "Basic YWRtaW46c2VjcmV0MTIz"
}
2. Server JSON Response (HTTP 200 OK)
{
"authenticated": true,
"user": "admin",
"active_connections": 142,
"memory_usage_mb": 284.5
}
Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)
curl -X GET "https://cometflow.space/api/v1/admin/metrics" \
-u "admin:secret123"
const credentials = btoa('admin:secret123');
fetch('https://cometflow.space/api/v1/admin/metrics', {
headers: {
'Authorization': `Basic ${credentials}`
}
}).then(res => res.json()).then(console.log);
import requests
from requests.auth import HTTPBasicAuth
res = requests.get('https://cometflow.space/api/v1/admin/metrics', auth=HTTPBasicAuth('admin', 'secret123'))
print(res.json())
How This API Call Works Step-by-Step
- 1. String concatenation: admin + ":" + secret123.
- 2. Base64 encoding: YWRtaW46c2VjcmV0MTIz.
- 3. Header attached: Authorization: Basic <base64>.
- 4. Server decodes and verifies against internal credentials.
Backend API Functions: The API function basicAuthMiddleware() parses the header, decodes buffer from base64, splits on colon, and authenticates the user.
Frequently Asked Questions
Is Basic Auth secure?
Basic Auth is only secure over HTTPS (encrypted TLS). If sent over plain HTTP, anyone sniffing network traffic can instantly decode the Base64 credentials.