← Back to Home

Basic Auth

/basic-auth/:user/:password
Tests HTTP Basic Authentication. Returns 401 if credentials are incorrect, 200 if correct.

Parameters

user path
Expected username
password path
Expected password

Examples

curl
# Test basic auth with username "john" and password "secret"
curl -u john:secret https://tcpdata.com/basic-auth/john/secret
JavaScript (fetch)
const username = 'john';
const password = 'secret';
const credentials = btoa(`${username}:${password}`);

fetch('https://tcpdata.com/basic-auth/john/secret', {
  headers: {
    'Authorization': `Basic ${credentials}`
  }
})
  .then(res => res.json())
  .then(data => console.log(data));
Python (requests)
import requests
from requests.auth import HTTPBasicAuth

response = requests.get('https://tcpdata.com/basic-auth/john/secret',
    auth=HTTPBasicAuth('john', 'secret'))
print(response.json())