Proxy authentication methods decide how a proxy knows a connection is yours. Commercial proxies use two main approaches: username and password, sent with each connection, or IP allowlisting, where the provider accepts any connection from IP addresses you've registered. Each has trade-offs for security, portability and tooling. Understanding how they work on the wire also makes most authentication errors easy to fix.
Username and Password Authentication
For HTTP proxies, credentials travel in the Proxy-Authorization header using the Basic scheme: the string username:password, Base64-encoded. For HTTPS sites, the header is attached to the CONNECT request that opens the tunnel:
CONNECT example.com:443 HTTP/1.1
Host: example.com:443
Proxy-Authorization: Basic VVNFUk5BTUU6UEFTU1dPUkQ=That value is just USERNAME:PASSWORD encoded, which you can verify:
echo -n "USERNAME:PASSWORD" | base64
# VVNFUk5BTUU6UEFTU1dPUkQ=Base64 is an encoding, not encryption. Anyone who can see the CONNECT request can read the credentials. In practice the hop from you to the proxy runs over your own network, but don't send proxy credentials across untrusted networks without another layer of protection, and rotate them if they leak.
SOCKS5 has its own username/password sub-negotiation (RFC 1929) that happens before the connection request, also unencrypted. See what is a SOCKS5 proxy.
Strengths
- Works from anywhere: laptop, server, CI runner, a friend's network, a dynamic IP.
- The username can carry options. Providers use it to pass country, session and other settings per connection.
- Easy to rotate or revoke without touching network settings.
Weaknesses
- Credentials sit in config files and scripts, where they can leak through repos or logs.
- Some clients handle proxy credentials poorly: certain browsers' command-line flags, some older libraries, and Java for HTTPS tunnels unless configured.
IP Allowlisting
With IP allowlisting (or whitelisting), you register the public IPs of your machines in the provider's dashboard. Any connection from those IPs is accepted with no credentials.
- Strength: no secrets in your code, and tools without proxy-auth support just work.
- Weakness: breaks when your IP changes, which is common on home connections, mobile networks and cloud instances.
- Weakness: dangerous behind CGNAT or shared office IPs, because everyone sharing your public IP could use your proxy.
- Weakness: options such as country or session have to be selected some other way, often through different ports or hostnames.
Which Method Should You Use?
- Fixed servers with static IPs and tools that can't send credentials: allowlisting is convenient, where offered.
- Laptops, dynamic IPs, CI, containers, anything that moves: username and password.
- When you need per-request control of country or session: username and password, because the options live in the username.
Passing Credentials Correctly
curl
# In the URL (encode special characters in the password)
curl -x http://USERNAME:[email protected]:8080 https://api.ipify.org
# Separately, which avoids URL-encoding issues
curl -x http://global.nodeproxies.xyz:8080 --proxy-user "USERNAME:PASSWORD" https://api.ipify.orgPython requests
import os
import requests
from urllib.parse import quote
user = os.environ["PROXY_USER"]
pw = quote(os.environ["PROXY_PASS"], safe="")
proxy = f"http://{user}:{pw}@global.nodeproxies.xyz:8080"
print(requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=30).text)quote() escapes characters like @, : and # that would otherwise break the URL. Reading credentials from environment variables keeps them out of your source code.
Node.js
// npm install https-proxy-agent
const https = require("https");
const { HttpsProxyAgent } = require("https-proxy-agent");
const user = process.env.PROXY_USER;
const pass = encodeURIComponent(process.env.PROXY_PASS);
const agent = new HttpsProxyAgent("http://" + user + ":" + pass + "@global.nodeproxies.xyz:8080");
https.get("https://api.ipify.org", { agent }, (res) => {
res.on("data", (chunk) => process.stdout.write(chunk));
});encodeURIComponent() does the same job as Python's quote(). Node's built-in fetch doesn't take an agent option, so use the https module as above, or axios. Our Node.js, axios and Puppeteer guide has complete working examples.
When Authentication Fails
A 407 Proxy Authentication Required means the proxy didn't accept what you sent, or the client didn't send it at all. On NodeProxies it means wrong credentials or an inactive plan; a 402 means the plan is out of bandwidth. Work through the 407 checklist: typos, unencoded special characters, options added to the password instead of the username, and clients that don't send credentials on CONNECT.
How NodeProxies Authenticates
NodeProxies uses username and password authentication on both HTTP (port 8080) and SOCKS5 (port 1080). Country and session options go in the username, and the proxy username builder assembles them for you. Create an account to get credentials, see API details in the docs, or check pricing.
FAQ
What is proxy authentication?
The way a proxy verifies a connection belongs to a paying user, usually by username and password in the Proxy-Authorization header or by checking the client's IP against an allowlist.
Is proxy Basic authentication secure?
The credentials are only Base64-encoded, so they're readable by anyone who can see the traffic to the proxy. Keep them out of shared code and rotate them if exposed.
Why does my proxy ask for a username and password in the browser?
The browser received a 407 and is prompting for credentials. Enter your proxy username and password, or use an extension that supplies them.
Can I use IP allowlisting with NodeProxies?
NodeProxies authenticates with username and password, which works from any network and carries country and session options.
