# Test basic auth with username "john" and password "secret"
curl -u john:secret https://tcpdata.com/basic-auth/john/secret
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));
import requests
from requests.auth import HTTPBasicAuth
response = requests.get('https://tcpdata.com/basic-auth/john/secret',
auth=HTTPBasicAuth('john', 'secret'))
print(response.json())