- Docs
- Core Concepts
- Authentication
- Basic Authentication
Basic Authentication
Simple username and password authentication for QPub services.
Overview
Basic authentication provides a straightforward way to authenticate using username and password credentials.
Usage
SDK Authentication
// Initialize client with basic auth
const client = new QPubSocket({
username: 'your-username',
password: 'your-password'
});REST API Authentication
# Using curl with basic auth
curl -u username:password \
https://api.qpub.com/v1/channels
# Or with Authorization header
curl -H "Authorization: Basic $(echo -n 'username:password' | base64)" \
https://api.qpub.com/v1/channelsConfiguration
Client Setup
const client = new QPubSocket({
endpoint: 'wss://api.qpub.com',
auth: {
type: 'basic',
username: 'your-username',
password: 'your-password'
}
});Connection with Basic Auth
// Connect with basic authentication
await client.connect({
auth: {
username: 'your-username',
password: 'your-password'
}
});Security Considerations
HTTPS/WSS Only
Always use encrypted connections (HTTPS/WSS) when using basic authentication to protect credentials.
Password Security
- Use strong, unique passwords
- Consider using password managers
- Implement password rotation policies
Alternative Authentication
For production applications, consider using:
- API tokens for better security
- OAuth for third-party integrations
- JWT tokens for stateless authentication
Error Handling
client.on('auth_error', (error) => {
console.error('Authentication failed:', error.message);
if (error.code === 'INVALID_CREDENTIALS') {
console.log('Please check your username and password');
}
});This page is under construction. Basic authentication documentation will be expanded soon.
Previous
Overview
Next
Token Auth